Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using CAST to TIMESTAMP in Where clause for Between

ArkatktFeb 6 2018 — edited Feb 6 2018

Hello,

I am trying to use the CAST function as part of the where clause.  Is it possible?

[code]

SELECT T.*, CAST(S.SENDSCHEDDT AS TIMESTAMP),

FROM MASTER T INNER JOIN SCHEDULE S on T.SCHEDULEID=S.SCHEDULEID

WHERE T.STATUSCD=1

AND T.ENABLEDFLAG = 1

AND S.SENDSCHEDDT BETWEEN TO_TIMESTAMP('2018-02-05 19:17:59', 'yyyy-MM-dd HH24:mi:ss')

AND TO_TIMESTAMP('2018-02-05 19:18:29', 'yyyy-MM-dd HH24:mi:ss')

[/code}

Instead of the TO_TIMESTAMP, I would like to avoid it.  I thought of using the CAST there or reference it from the select clause?  Possible?  I tried

[code]
AND S.SENDSCHEDDT BETWEEN CAST('2018-02-04 19:17:59' AS TIMESTAMP)

AND CAST('2018-02-05 19:18:29' AS TIMESTAMP)
[/code]
But I get ORA-01843: not a valid month

Any advice is appreciate.

Running 12cR1

This post has been answered by Solomon Yakobson on Feb 6 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 6 2018
Added on Feb 6 2018
9 comments
16,002 views