Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: question about working with dates and times

From   "Visintainer, Paul" <>
To   "''" <>
Subject   st: question about working with dates and times
Date   Mon, 26 Jul 2010 19:43:29 -0400

I'm having a little difficulty working with dates and times as doubles.  I want to add to an existing date an interval that is 24 hours (or even larger).  The following code works:

.gen double day0 = tc("06oct2007 00:00:00")     // e.g., existing date   (1)

.gen double day1 = day0 + tc(23:59:59) + tc(00:00:01)  // 24-hr interval (2)

.format day0 day1 %tc

.list day0 day1 in 1

     |               day0                 day1 |
  1. | 06oct2007 00:00:00   07oct2007 00:00:00 |

But, step 2 seems cumbersome (because tc(24:00:00) is an invalid value.)

When working with dates/times as doubles, I suspect there is a simpler approach for adding large intervals (e.g., 36 hours, or 2 weeks, or 3 months, etc).  Any help would be appreciated.


Paul F. Visintainer, PhD
Baystate Medical Center
Springfield, MA 01199

Please view our annual report at

CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may contain confidential and privileged information for the use of the designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its contents is prohibited. If you have received this communication in error, please reply to the sender immediately or by telephone at 413-794-0000 and destroy all copies of this communication and any attachments. For further information regarding Baystate Health's privacy policy, please visit our Internet site at

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index