BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DanD999
Quartz | Level 8

I pulled this date from sql server and tried putting single quotes around it but that didn't work. I saw somewhere that %bquote was used so I tried that too. Any suggestions appreciated.

 

proc sql inobs=7;

connect to SQLSVR (user=&user. Password=&pass. dsn=&db.);

create table members as

select * from connection to SQLSVR

(

select *

from jkl.table1

where entered_dt >= '22OCT2018:07:00:00.0000000'

);

disconnect from sqlsvr;

quit;

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanD999
Quartz | Level 8

@RichardDeVen wrote:

Try

YYYY-MM-DD

So

where entered_dt >= '2018-11-22'

This works '2020-11-22 07:00:00'. Thanks for getting me on the right track.

View solution in original post

6 REPLIES 6
RichardDeVen
Barite | Level 11

Try

YYYY-MM-DD

So

where entered_dt >= '2018-11-22'
DanD999
Quartz | Level 8

@RichardDeVen wrote:

Try

YYYY-MM-DD

So

where entered_dt >= '2018-11-22'

The query runs successfully but it doesn't give the correct answer. How do I find rows where the time is after 7AM on that date?

 

Thanks

DanD999
Quartz | Level 8

@RichardDeVen wrote:

Try

YYYY-MM-DD

So

where entered_dt >= '2018-11-22'

If I change the datetime to '2020-10-22:07:00:00.0000000' I get this error:

 

ERROR: CLI open cursor error: [SAS][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]Conversion failed when converting

date and/or time from character string.

SASKiwi
PROC Star

A Google search will provide the answer:

 '2020-10-22 07:00:00'
DanD999
Quartz | Level 8

@RichardDeVen wrote:

Try

YYYY-MM-DD

So

where entered_dt >= '2018-11-22'

This works '2020-11-22 07:00:00'. Thanks for getting me on the right track.

SASKiwi
PROC Star

@DanD999  - Please mark the post as answered then.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1364 views
  • 2 likes
  • 3 in conversation