cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

BUG OR ERROR : Date UTC Method

virender_prajap
New Contributor III

Hi All,

I am using Date.UTC() method to generate last month date & using below syntax which seems to be fine.

Date.UTC(Date.now().minusMonths(1).getFullYear(),Date.now().minusMonths(1).getMonth(),0)

And output preview is also fine.
image

But while I am inserting data into Orcale DB, 1 day is getting subtracted from the date.
image

Not able to figure out where is the issue. Tried by changing date data type to varchar2 at DB levelโ€ฆbut the value remain same.

1 ACCEPTED SOLUTION

jaybodra
New Contributor III

@virender.prajapati I have seen this happening to me in MySQL. I used toLocalDateTimeString() function before inserting it into the DB and worked fine.

You can try this in your mapper,
Date.UTC(Date.now().minusMonths(1).getFullYear(),Date.now().minusMonths(1).getMonth(),0).toLocaleDateTimeString({โ€œformatโ€: โ€œyyyy-MM-dd HH:mm:ssโ€,โ€œtimeZoneโ€:โ€œUTCโ€})

You can also look into oracle jdbc url properties

View solution in original post

6 REPLIES 6

tstack
Former Employee

Looks like there is some timezone conversion being applied. The time in the preview is โ€œ00:00:00โ€, while the time in the other screenshot is โ€œ20:00:00โ€. Is the value being converted at some other point in the pipeline or oracle?

In pipeline data value remain same before the oracle insert snap, value is getting changed in Oracle DB.
But ideally it should insert value passed by pipeline only. Seems like in Oracle insert Snapโ€ฆoracle timestamp is used which is generating this kind of problem.

jaybodra
New Contributor III

@virender.prajapati I have seen this happening to me in MySQL. I used toLocalDateTimeString() function before inserting it into the DB and worked fine.

You can try this in your mapper,
Date.UTC(Date.now().minusMonths(1).getFullYear(),Date.now().minusMonths(1).getMonth(),0).toLocaleDateTimeString({โ€œformatโ€: โ€œyyyy-MM-dd HH:mm:ssโ€,โ€œtimeZoneโ€:โ€œUTCโ€})

You can also look into oracle jdbc url properties

@virender.prajapati Can I ask if the snaplex nodes or OracleDB have a timezone set to something other than UTC?