Subtract TimeStamps

Reply
New Contributor
Posts: 4

Subtract TimeStamps

I have 2 TimeStamp fields . I would like to subtract one from another and have the difference in seconds.

Could someone tell me how can i do this ?

Note, sometime the difference between the timestamps can be more than one day.

PROC Star
Posts: 1,227

Re: Subtract TimeStamps

What do you mean by timestamp field?  If the value is a SAS date-time, then it is a numeric value which is the number of seconds since Jan 1, 1960.  In that case you can just subtract timestamp2-timestamp1 to find the difference in seconds.

If the timestamps are stored in a character field, please show the format of the character string.  It should be straight forward to convert them to SAS date-time, and then do the subtraction.

New Contributor
Posts: 4

Re: Subtract TimeStamps

i think i got it... .it's in seconds already, so just subtracting one by other i have difference. thanks !

Ask a Question
Discussion stats
  • 2 replies
  • 209 views
  • 0 likes
  • 2 in conversation