Marc, thanks a lot! That works like a charm.
Best wishes,
Alexander
-----Opprinnelig melding-----
Fra: [email protected] [mailto:[email protected]] P� vegne av Marc N. Sch�ssler
Sendt: 28. august 2008 14:58
Til: [email protected]
Emne: Re: st: Time of day
Hi Alexander,
i suggest you to get a numeric date based on milliseconds and then grap with the time of day- funktion the needed component, here hours (type "help date" and there see "extracting date and time components").
gen double timevar = clock(result_date, "DMYhms") gen hourvar = hh(timevar)
you might want to keep your new timevar, then bring it with format timevar %tc to a more readable format.
hope this helpes you
Marc
Am 28.08.2008 um 12:54 schrieb <[email protected]>
<[email protected]>:
> Dear Statalister,
>
> I use Stata 10. I have a string variable, result_date, that records
> day, month, year, hours, minutes, seconds. It displays, 11.02.2008
> 08:21:00.000
>
> I would like to generate a new variable that only indicates hours.
> I had a look at the ntimeofday, written by Nicholas J. Cox (findit
> ntimeofday), and issed the following command,
>
> ntimeofday result_date, gen(ndatetime) s(dmy h mi s) n(h)
>
> It runs ok, but listing some of these values gives me
>
> list ndatetime in 1/2
> | ndatetime |
> |-----------|
> 1. | 421760.35 |
> 2. | 421759.92 |
>
> I am not sure whether I am on the right track, and maybe all I am
> missing is to translate these numbers into hours? Any help would be
> greatly appreciated.
>
> Best wishes,
> Alexander Severinsen
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/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/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/statalist/faq
* http://www.ats.ucla.edu/stat/stata/