DATA Step, Macro, Functions and more

select records where the date (in date time format) is less than today

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 129
Accepted Solution

select records where the date (in date time format) is less than today

Hi,

 

I have a field (table_date) that's in date time format: (sample: 08MAY2017:08:00:00.000) and I want to select records where the date is less than today()

 

here is what I have so far but it's not working

 

 

proc sql;
create table temp_del1
as
select * from temp_weekly_data
where
datepart(table_date) < datepart(today());
run;

 

please advise


Accepted Solutions
Solution
‎05-19-2017 03:47 PM
PROC Star
Posts: 7,364

Re: select records where the date (in date time format) is less than today

Remove the datepart function from the today() function. i.e.,

datepart(table_date) < today();

Also, end your proc sql call with a quit; rather than a run; statement

 

Art, CEO, AnalystFinder.com

 

View solution in original post


All Replies
Solution
‎05-19-2017 03:47 PM
PROC Star
Posts: 7,364

Re: select records where the date (in date time format) is less than today

Remove the datepart function from the today() function. i.e.,

datepart(table_date) < today();

Also, end your proc sql call with a quit; rather than a run; statement

 

Art, CEO, AnalystFinder.com

 

Frequent Contributor
Posts: 129

Re: select records where the date (in date time format) is less than today

thanks for your assistance

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 101 views
  • 0 likes
  • 2 in conversation