Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: convert date in string data type to integer data type
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: convert date in string data type to integer data type
Date
Thu, 29 Nov 2012 15:55:53 +0000
The help for dates does explain how to do this.
gen mydate = date(mystr, "MDY")
format mydate %whatever
Note that you don't override the original.
Nick
On Thu, Nov 29, 2012 at 3:23 PM, Whitney Cox <[email protected]> wrote:
> I have a Stata .dta file that contains a date in a str10 data type field
> with the format of %10s that displays a date as 01/31/2012
> I want to convert it to an integer data type with the format
> %tdNN/DD/CCYY, which displays as 01/31/2012
>
> What should my command be to do that?
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/