I am trying to transition from Oracle to redshift and got stuck with this function conversion. Can someone help me with this?
Oracle: trunc(to_date('{RUN_DATE_YYYYMMDD}', 'YYYYMMDD')-6, 'DAY')
RedShift: ?
You are actually getting the date without the time part.
In Redshift, you can simply use
'{RUN_DATE_YYYYMMDD}' :: date - 6
or
to_date('{RUN_DATE_YYYYMMDD}', 'YYYYMMDD')-6
Related
hi guys a need your help, I'm migrating some stored procedures from sybase to oracle, and I don't know how to transform this line to oracle.
select #date_vig_aux = dateadd(ss,-1,#date_vig_aux)
I would appreciate if you help me.
Supposing date_vig_aux is defined as DATE or TIMESTAMP in pl/sql, this should translate into
date_vig_aux:=date_vig_aux+numtodsinterval(-1,'second');
I was originally using LISTAGG to do the union of strings in oracle.
Searching for PostgreSQL I get: string_agg
I don't know if there is any way to have a function that works in both applications.
I have to do it from the query since I can't create functions
thanks for your help
Thank you all for the help, in the end I did it through functions and sub-query
I am trying to transition from Oracle to redshift and got stuck with this function conversion. Can someone help me with this?:
Oracle:
RESOLVED_DATE BETWEEN DATE_TRUNC(TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD'),'Y') AND TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD')
RedShift: ?
I am trying to get date from start of the year to the query run date.
You can use
select ...
where RESOLVED_DATE between date_trunc('year',current_timestamp) and current_timestamp;
Currently, I am working on migrating an Oracle database schema to Postgres. As part of it I have to convert a custom utility function in Oracle which generates timestamps based on timezone. But the values obtained from Oracle and Postgres seem to vary by one hour.
Oracle:
SELECT (to_timestamp_tz('20300714 235959 CET','YYYYMMDD HH24MISS TZR') - to_timestamp_tz('19700101 000000 GMT','YYYYMMDD HH24MISS TZR'))
as foo FROM dual;
yields +22109 21:59:59.000000
Postgres:
select ('20300714 235959'::timestamp AT TIME ZONE 'CET') - ('19700101 000000'::timestamp AT TIME ZONE 'GMT') as foo;
yields 22109 days 22:59:59
I guess the reason for this difference is because of daylight saving but I am not sure. Can anyone help me out with this problem.
I am using Postgres v9.6 and Oracle 12c.
Well, I found the mistake I was doing. Postgres seems to handle the abbreviated timezone name and full timezone name differently. In case if you want to incorporate daylight related changes you would have to use full timezone name. In my case using 'Europe/Amsterdam' instead of 'CET' yielded the same result as that of Oracle.
To find the complete list of full timezone names supported by Postgres, I used the query:
select * from pg_timezone_names where abbrev='CET';
I am facing a strange problem , when I connecting Oracle from SSIS and running below query it is not applying filter criteria
SELECT * FROM Table_Schema.Table_Name where trunc(Date_Column) >='01-APR-14'
but this is giving me data older than 01 April also. But when I am running same query in Oracle it is working absolutely fine.
What is wrong here?
Have you tried applying a format mask to the date you are passing in - you should always do this by default. You could substitute your date for sysdate (or getdate() in sqlserver) and see if it performs correctly. Also try removing the trunc.