July 31, 2017 at 2:57 pm
I have to connect to source PostgreSQL and pull some data. Thing is i did not work on PostgreSQL before.
I was trying to do same as tsql and realized i was doing wrong. Can anyone help me re-write TSQl query to PostgreSQL?
Trying to get the yesterday data from morning till midnight. Something like below.
WHERE
(
(lastupdateddate > DATEADD(DAY, DATEDIFF(DAY, 0, GetDate()) -1, 0)
AND lastupdateddate <= DATEADD(DAY, 0, GETDATE())
)
July 31, 2017 at 6:47 pm
There are some people on this site who work with PostgreSQL, but you'll probably get a quicker response by posting your question to a PostgreSQL forum.
August 1, 2017 at 6:45 am
I don't have a psotgres linked server any more, but the key was how adding or subtracting to a date is different.
CURRENT_TIMESTAMP and CURRENT_DATE give you GETDATE() or getdate() with no time.
Adding and subtracting time uses the + INTERVAl statement
ie
SELECT CURRENT_DATE + INTERVAL '1 day';
so i *think* you are looking for something like this:
WHERE
(
(lastupdateddate > (CURRENT_DATE - INTERVAL '1 day')
AND lastupdateddate <= CURRENT_DATE
)
Lowell
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply