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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 4 replies
  • 1323 views
  • 1 like
  • 3 in conversation