Home > Mobile >  How to pass bash date into sql timestamp
How to pass bash date into sql timestamp

Time:06-11

Hello i have code like this:

...AND o.creation_date > TO_DATE($DATE_TODAY, 'YYYYMMDD')...

When i want to pass variable into function TO_DATE it works.

But in another script, I have code like this...

    ...AND o.creation_date > TO_TIMESTAMP( $DATE_TODAY , 'YYYYMMDD')...

And in this case when i try pass $DATE_TODAY into function TO_TIMESTAMP i get error:

AND o.creation_date > TO_TIMESTAMP( 20220610 , 'YYYYMMDD') error in line 30:
ORA-00932 inconsistent datatypes Expected -, NUMBER obtained

I need to pass date in single quotes like '20220610', Is it possible to do this?

CodePudding user response:

You should put single quotes in the script, there is no need to escape them. Just do:

AND o.creation_date > TO_TIMESTAMP( '$DATE_TODAY' , 'YYYYMMDD')
  • Related