โ10-13-2018 10:50 PM
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.
But while I am inserting data into Orcale DB, 1 day is getting subtracted from the date.
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.
Solved! Go to Solution.
โ10-18-2018 12:04 PM
@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
โ11-19-2018 02:11 AM
Yes, Oracle DB & Snaplex set to different time zonesโฆthatโs why it was happening.
Thanks for your support.
โ11-19-2018 02:10 AM
Thanks @jaybodra , It is working fine.