DATA Step, Macro, Functions and more

Simple Date Informat Question

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

Simple Date Informat Question

i have data in is8601 dt format.

eg:-'2016-09-15T12:40:23'.

i want to calculate number of days from 1960-01-01.

how do i get that

 


Accepted Solutions
Solution
‎06-29-2016 08:05 AM
Trusted Advisor
Posts: 1,137

Re: Simple Date Informat Question

Posted in reply to vinit_correia
data have;
date1='2016-09-15T12:40:23';
date2='1960-01-01';
run;

data want;
set have;
days=intck('day',input(date2,yymmdd10.),datepart(input(date1,is8601dt.)));
run;
Thanks,
Jag

View solution in original post


All Replies
Solution
‎06-29-2016 08:05 AM
Trusted Advisor
Posts: 1,137

Re: Simple Date Informat Question

Posted in reply to vinit_correia
data have;
date1='2016-09-15T12:40:23';
date2='1960-01-01';
run;

data want;
set have;
days=intck('day',input(date2,yymmdd10.),datepart(input(date1,is8601dt.)));
run;
Thanks,
Jag
Occasional Contributor
Posts: 9

Re: Simple Date Informat Question

Posted in reply to Jagadishkatam

thanks ...that was very helpful

Occasional Contributor
Posts: 9

Re: Simple Date Informat Question

Posted in reply to vinit_correia

wouold it work if there wasnt a T in Date1?

Trusted Advisor
Posts: 1,137

Re: Simple Date Informat Question

Posted in reply to vinit_correia
Since we used the informat is8601dt, we are expecting a T in the date1. Else it will not work.
Thanks,
Jag
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 335 views
  • 2 likes
  • 2 in conversation