| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
RE: st: date format changed to number - why?
Nick's feedback helped me write more succinct code and Anders reference
to datestring solved the problem.
Many thanks to you both and hopefully one day I can return the favor!
Cheers,
Paul
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Anders
Alexandersson
Sent: Thursday, December 07, 2006 4:46 PM
To: [email protected]
Subject: Re: st: date format changed to number - why?
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/
*
* 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/