Statalist The Stata Listserver


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

Re: st: date format changed to number - why?


From   "Anders Alexandersson" <[email protected]>
To   [email protected]
Subject   Re: st: date format changed to number - why?
Date   Thu, 7 Dec 2006 16:46:23 -0500

Please show us the odbc and describe commands that you used and what
Stata outputted. It might be a problem with the data type. The string
data type should be safe; to read dates as strings use the datestring
option.

Anders Alexandersson
[email protected]

Bednar, Paul <[email protected]> wrote:
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...
*
*   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