Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: date format changed to number - why?


From   "Bednar, Paul" <[email protected]>
To   [email protected]
Subject   st: date format changed to number - why?
Date   Thu, 7 Dec 2006 16:24:32 -0500

Dear Statalisters,

When I import a date variable using odbc Stata changes the format from
yyyy-mm-dd to mmddyyyy--for example, 2002-07-01 to 01Jul2002.

I need to convert the date variable back to yyyy-mm-dd to be in the
proper database format.  I do this in the following manner (variable is
datevar1):

foreach var in varlist datevar1 {
  format datevar1 %dCY-N-D
}

Listing datevar1 via the command line displays the data in the proper
yyyy-mm-dd format.  However, using odbc I get an "incorrect date value:
'1522'" error message, as the date variable somehow has been converted
to a number (date should be 2002-07-01).

Please help me understand the error of my ways...

Cheers,
Paul



*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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