I need to calculate the elapsed time in hours between two events, each
specified by a date variable and a string "hh:mm" where hh is 0 to 23
and mm is 0 to 59. For example...
begindate begintime enddate endtime
---------------------------------------------
07jul2004 22:30 09jul2004 12:30
I found the str2time command which converts a string variable containing
times in this 24 hour clock format (HH:MM or HH:MM:SS) into an elapsed
time format (a numeric value between 0 and 1) available at:
http://www.sealedenvelope.com/stata_tim.php
-->
str2time begintime, generate(fbegintime)
begintime(string) fbegintime
03:17 .13680556
15:26 .64305556
I'm struggling with the stata code to format each date as elapsed days
since 01jan1960, convert into a real number, add the fractional part,
then subtract to find elapsed time in days.
Thanks!
Dale
Douglas Crawford wrote:
> Hi,
>
> The egenmore manual suggests that I can format the result of dhms:
>
> dhms(d h m s) [ , format(format) ]
>
> but the %t formats available do not seem to permit units smaller than a day
> (with an emphasis on larger units such as quarter). Ideally I would like to
> display any of the following:
>
> date:hh:mm
> d:hh:mm
> hh:mm
> hh:mm:ss
>
> I don't want to generate a string, just display the results of dhms in an
> attractive a manner as the date formats. The list archive suggests that
> this is a wish-list item, but I am hoping I missed something.
>
> Thanks, as always, for your help.
>
> Cheers,
>
> Douglas
>
>
>
>
> *
> * 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/