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 copied the datetime out of the table but I get an error. The format is

CREAT_DTTM num format=DATETIME24.3 informat=DATETIME24.3 label='CREAT_DTTM',

and hsc.CREAT_DTTM >= '25MAR2014:14:04:41.652'
and hsc.CREAT_DTTM <= '25MAR2014:14:15:46.424'

ERROR: ORACLE execute error: ORA-01849: hour must be between 1 and 12.

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

Are you passing this values within implicit or explicit SQL code. 

If it's withing implicit SAS SQL code (=not within a connect to ... bit) then you need to tell SAS that it needs to interpret the string as a datetime value by adding dt after the quote.

and hsc.CREAT_DTTM >= '25MAR2014:14:04:41.652'dt
and hsc.CREAT_DTTM <= '25MAR2014:14:15:46.424'dt

If above works then you're facing another challenge which is about precision when moving floating point values between environments. Let's address this if above is what makes things work.

 

If it's pass-through SQL then you need to instruct Oracle to interpret the string as a timestamp value. The To_Timestamp() function allows for this.

 

 

View solution in original post

4 REPLIES 4
andreas_lds
Jade | Level 19

It seems that oracle expects time in am/pm notation, the format DATEAMPM30.3 should display the datetime in the expected format.

DanD999
Quartz | Level 8

If you're suggesting to change the format of the column to DATEAMPM30.3 that is not possible. I have no control over the format that was chosen. Thanks.

Patrick
Opal | Level 21

Are you passing this values within implicit or explicit SQL code. 

If it's withing implicit SAS SQL code (=not within a connect to ... bit) then you need to tell SAS that it needs to interpret the string as a datetime value by adding dt after the quote.

and hsc.CREAT_DTTM >= '25MAR2014:14:04:41.652'dt
and hsc.CREAT_DTTM <= '25MAR2014:14:15:46.424'dt

If above works then you're facing another challenge which is about precision when moving floating point values between environments. Let's address this if above is what makes things work.

 

If it's pass-through SQL then you need to instruct Oracle to interpret the string as a timestamp value. The To_Timestamp() function allows for this.

 

 

DanD999
Quartz | Level 8

Patrick,

I'm sorry it took me so long to get back to this but it worked. Thanks a lot.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1656 views
  • 1 like
  • 3 in conversation