how to compare date with current date?

Reply
Occasional Contributor
Posts: 10

how to compare date with current date?

if input(Date_Stop,yymmdd8.) < %sysfunc(today(),yymmddn8.) then do;errordes5='Invalid Date_Stop'; end ;

 

how to compare date with current date? above statements don't work, please help, thanks!

Grand Advisor
Posts: 17,461

Re: how to compare date with current date?

Please take a minute to format your code. The followin gis the correct comparison, assuming your date variable is a character and formatted as yymmdd.

 

input(Date_Stop,yymmdd8.) < today() 
Esteemed Advisor
Posts: 7,300

Re: how to compare date with current date?

Your code appears like your stop_date is a character field. If so, then the following should work:

 

data have;
  input date_stop $;
  if input(Date_Stop,yymmdd8.) < today() then do;
    errordes5='Invalid Date_Stop';
  end ;
  cards;
20151012
20170322
20170323
;

Art, CEO, AnalystFinder.com

Contributor
Posts: 55

Re: how to compare date with current date?

Please provide more details on the requirement like what exactly you are trying to achieve. If date is compared with current date then what you want to achieve.

Ask a Question
Discussion stats
  • 3 replies
  • 147 views
  • 0 likes
  • 4 in conversation