Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Re: changing format


From   Nishant Dass <[email protected]>
To   [email protected]
Subject   Re: st: Re: changing format
Date   Thu, 16 Oct 2008 12:41:16 -0700 (PDT)

Hi Martin,

Thank very much!

I used the following command for the duration (in years) between my two dates:

. gen maturity = (date(maturitydate, "DMY") - date(offerdate, "DMY"))/365

The page <http://www.stata.com/help.cgi?dates_and_times#how> had more useful details. 

Nishant




--- On Thu, 10/16/08, Martin Weiss <[email protected]> wrote:

> From: Martin Weiss <[email protected]>
> Subject: st: Re: changing format
> To: [email protected]
> Date: Thursday, October 16, 2008, 3:24 PM

> see -help dates_and_times##str2num-
> 
> HTH
> Martin
> _______________________
> ----- Original Message ----- 
> From: "Nishant Dass"
> <[email protected]>
> To: "STATA Help"
> <[email protected]>
> Sent: Thursday, October 16, 2008 9:16 PM
> Subject: st: changing format
> 
> 
> > Hi,
> >
> > I am using Stata 10.0 for Windows and I have a small
> question about the 
> > "format" of variables:
> >
> > I have several date variables that appear as string
> variables in my Stata 
> > dataset (reported as "31JAN2008", for
> instance):
> >
> >              storage  display     value
> > variable name   type   format      label      variable
> label
> >
> -------------------------------------------------------------------------------
> > maturitydate    str9   %9s                   
> MaturityDate
> > offerdate       str9   %9s                   
> OfferDate
> >
> >
> > I need to find the duration between these two dates so
> I am trying to 
> > change them to a date format as follows:
> >
> > . format maturitydate offerdate %td
> >
> > But I get the following error:
> >
> > "string %fmt required for string variables"
> >
> > Could someone tell how can I change string variables
> to dates?
> >
> > Thank you!
> >
> > Nishant
> >
> >
> >
> > *
> > *   For searches and help try:
> > *   http://www.stata.com/help.cgi?search
> > *   http://www.stata.com/support/statalist/faq
> > *   http://www.ats.ucla.edu/stat/stata/
> > 
> 
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/


      
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index