DATA Step, Macro, Functions and more

auto fetching of dates

Accepted Solution Solved
Reply
Contributor
Posts: 69
Accepted Solution

auto fetching of dates

Hi ,

I am looking for auto date fetching;

e.g start date='05feb2018'd 

i want to fetch auto date for every next month i.e. 5th day of every month should be the start date.

.eg. for next month when the program is auto run it should fetch the start date as 5th day of next month.

 

Similarly end date should be last day of every current month.

e.g end_date='28thfeb2018'd for feb ...for march it should fetch the last date e.g. end_date='31March2018'.

 

Also let me know how can we code it in EG using the query builder.

 

Thanks


Accepted Solutions
Solution
‎02-26-2018 01:31 AM
Esteemed Advisor
Posts: 5,482

Re: auto fetching of dates

intnx gives you all the flexibility. You should really look into it.

 

data want;
format startDate endDate yymmdd10.;
startDate = intnx("day",intnx("month", today(),1),4);
endDate = intnx("month", today(),0,"end");
run;

proc print data=want; run;




PG

View solution in original post


All Replies
Esteemed Advisor
Posts: 5,482

Re: auto fetching of dates

Use the date interval function intnx:

 

data want;
format startDate endDate yymmdd10.;
startDate = intnx("day",intnx("month", today(),0),4);
endDate = intnx("month", today(),0,"end");
run;

proc print data=want; run;




PG
Contributor
Posts: 69

Re: auto fetching of dates

Sorry for start date the month should be the next month.i.e. if end date=28feb2018 then start date should be 5march2018
Solution
‎02-26-2018 01:31 AM
Esteemed Advisor
Posts: 5,482

Re: auto fetching of dates

intnx gives you all the flexibility. You should really look into it.

 

data want;
format startDate endDate yymmdd10.;
startDate = intnx("day",intnx("month", today(),1),4);
endDate = intnx("month", today(),0,"end");
run;

proc print data=want; run;




PG
Contributor
Posts: 69

Re: auto fetching of dates

Thanks a lot for the code,
missed the simple understanding in hurry.
☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 136 views
  • 0 likes
  • 2 in conversation