Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73345

Combine date and time - time is wrong after conversion

$
0
0
Dear all,

I am dealing with an apparently easy task. I am trying to combine in one column of date-time, two separate columns containing respectively a date and a time. The date is stored in date format (counting the number of days from January 1st, 1960); the time is stored as SIF datetime/c format. To combine them, I created the datetime column. But the result is quite surprising because the time is always wrong by a couple of seconds. Here is the code I used to obtain the results that are in the data set extract enclosed.

Code:
gen time=Clock(activation_time, "hms")
format time %tcHH:MM:SS
gen datetime=date*24*60*60*1000+time
format datetime %tCDD/NN/CCYY_HH:MM:SS
I tried to look at previous posts but no one seems to deal with the problem...

Many thanks in advance for your help.
Riccardo

Viewing all articles
Browse latest Browse all 73345

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>