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]

Re: st: duplicated datetime variable differs from original datetime variable it was derived from


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: duplicated datetime variable differs from original datetime variable it was derived from
Date   Tue, 12 Nov 2013 11:41:05 +0000

Phil has the answer in one. Unfortunately, you do have to keep
remembering that a date-time to Stata is just an integer, usually
large, giving time in milliseconds.

. di %14.0f clock("07jun2012 03:11:48", "DMYhms")
 1654657908000

Numbers that big have to be stored as -double-s.
Nick
[email protected]


On 12 November 2013 11:33, Phil Clayton <[email protected]> wrote:
> Dates with times need to be stored in double precision. Try:
> gen double time1=time
>
> See -help datetime-
>
> Phil
>
> On 12 Nov 2013, at 10:25 pm, Milena Przheska <[email protected]> wrote:
>
>> Dear Statalist members,
>>
>> When duplicating a time variable by typing
>>
>> gen time1 =time
>>
>> the new variable time1 is off by several seconds from the variable time, so
>>
>> time
>> 06jun2012 22:44:51
>> 06jun2012 22:44:54
>> 06jun2012 22:44:56
>> 07jun2012 01:39:58
>> 07jun2012 01:40:05
>> 07jun2012 01:40:45
>> 07jun2012 03:09:48
>> 07jun2012 03:09:48
>> 07jun2012 03:11:06
>>
>> becomes
>>
>> time1
>> 06jun2012 22:45:17
>> 06jun2012 22:45:17
>> 06jun2012 22:45:17
>> 07jun2012 01:40:03
>> 07jun2012 01:40:03
>> 07jun2012 01:40:03
>> 07jun2012 03:09:37
>> 07jun2012 03:09:37
>> 07jun2012 03:11:48
>>
>>
>> I would appreciate your help with resolving this problem.
>>
>> Thank you all,
>> Milena
>> *
>> *   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/
>
>
> *
> *   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/
*
*   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