Bookmark and Share

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]

st: Date format from string


From   Philipp Hagspiel <[email protected]>
To   [email protected]
Subject   st: Date format from string
Date   Tue, 11 Mar 2014 11:07:47 +0100

Hi,

I have imported and reshaped an excel file with dates as variables (observations after reshaping). They are now in the string format ddmmyyyy. They used to be in the format dd.mm.yyy in excel but I put a stub in front of every date, so Iguess that is why it didn't keep the date format.

When I know want to use the date function now, it tells me that there is a mismatch.

. gen eventdate = date(mydatevariable, "DMY")
    type mismatch
    r(109);

I have noticed that all dates that start with a "0" on the dd are converted into a d format.
So: 01.01.2001 --> 1012011, 20.01.2011 --> 20012011

Thus, I know have two formats: ddmmyyyy and dmmyyyy (whenever the day is between 01-09 it is now 1-9).

How can I fix this?

Thank you so much in advance!
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index