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: First date


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: First date
Date   Thu, 31 Jan 2013 11:53:43 +0000

Date-times for dates and times around now are in trillions (10^12 or
so) of milliseconds

. di %14.0f clock("02-Sep-2012 10:30:14", "DMYhms")
 1662201014000

so something is wrong with your variable -ndate_added-, because the
values you have are far too small.

More generally, what you should be doing is to add

date-time in milliseconds = date in milliseconds + time of day in milliseconds

but I guess what you are doing is adding

date-time in milliseconds = date in some other units + time in milliseconds

which won't work.

Note also that whatever display format you assigned to -ndate_added-
is quite immaterial; it's the numeric values underneath that format
that your calculation uses.

Nick

On Thu, Jan 31, 2013 at 11:31 AM, Keniajin Wambui <[email protected]> wrote:
> I am using stataIC 12.1 64bit on windows 7.
> I am calculating the first date the values for a given serial number
> given was entered
> The data example is
>
> time_done    ndate_added    serialNumber    dfst
> 8:01:50 PM    26-Feb-09    88358        72127954
> 4:56:27 PM    27-Feb-09    88358        61004955
> 12:30:27 PM    25-Mar-09    88358        45044981
> 10:30:14 PM    02-Sep-12    88358        81033238
>
>
> I am using the following code but its giving me (12:30:27 PM
> 25-Mar-09    88358)  as the first data to be entered but according to
> the data (8:01:50 PM    26-Feb-09    88358) was the first to be
> entered.
>
>     gen double timefst=clock(time_done, "hms")
>     replace timefst=clock(time_done, "hm") if timefst==.
>     format timefst %tc
>     format ndate_added %tc
>     gen dfst=ndate_added + timefst
>     egen double fdoadd = min(dfst), by(serialNumber)
>
> how can I solve the problem
*
*   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