BookmarkSubscribeRSS Feed
Saurabh77
Fluorite | Level 6

Hello All 

 

I have two dates in following format 

 

Date 1 - December 11, 2018 05:15:20PM 

Date 2 - January 21, 2018 01:25:21AM 

 

 

How can i calculate difference between these two date in HOURS ?

 

Thanks in Advance

7 REPLIES 7
novinosrin
Tourmaline | Level 20

data test;
char_Date1='December 11, 2018 05:15:20PM';
Num_date1=input(char_Date1,anydtdtm32.);
char_Date2='January 21, 2018 01:25:21AM';
Num_date2=input(char_Date2,anydtdtm32.);
Difference=abs(intck('DTHOUR',Num_date1,Num_date2));
format num_date: datetime20.;
run;
Saurabh77
Fluorite | Level 6
Hello Novinosrin

Thanks for the reply..What i am asking is simple function in SAS Visual Analytics to get the output.

This programe cannot possible to write in SAS VA
novinosrin
Tourmaline | Level 20

Oh I blame the damn!!!!!!!!!!!!!!!!! Dunkin Coffee(still not waking me up) that my eyes didn't even notice the VA in the question. My apologies. Best is to wait for somebody who knows VA to respond. Sorry about that.

JanSanford
Fluorite | Level 6
I am having the same issue but my datetime fields are formatted as 07OCT2018:10:14:00.00. Can you provide a solution for me?
novinosrin
Tourmaline | Level 20

Hi @JanSanford  I'm afraid I do not work with  SAS VA. Are you expecting a solution in  SAS VA?

SASKiwi
PROC Star

Datetimes are stored as seconds. You could just subtract one from the other then divide by 3,600 to convert to hours.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 976 views
  • 4 likes
  • 4 in conversation