Convertaing SAS Datetime to SQL Datetime

Reply
Highlighted
Frequent Contributor
Posts: 96

Convertaing SAS Datetime to SQL Datetime

Hi SAS Community.

 

This is what i am facing currently. I am having difficulty to convert SAS Datetime to SQL Datetime.

The display value in SAS Datetime is 28Mar2018:10:01:06 which is actually "28Mar2018:10:01:96"dt when doing Proc SQL.

The display value is SQL Datetime is 2018-03-28 10:01:06.000 which is actually '2018-03-28 10:01:06.000' when using SQL Pass through.

 

I have the SAS datetime value and want to use it in SQL Pass through statement. I have been finding online but i couldnt find any related information. The most i could find is only converting Date.

 

The Passthrough statement should be something like this(without the connect to xxx statement)

 

%let sasdatetime=2018-03-28 10:01:06.000;

/*How to convert the value above to SQL format and apply in proc sql below*/


Proc sql:

connect to xxx
select *

from table A

where birthdatetime = &thedatetime;

 

 

Seeking for your kind advice.

PROC Star
Posts: 2,370

Re: Convertaing SAS Datetime to SQL Datetime

Posted in reply to imdickson

Like this?

where birthdatetime = %nrbquote('&sasdatetime') ;

 

 

Ask a Question
Discussion stats
  • 1 reply
  • 140 views
  • 0 likes
  • 2 in conversation