I’m encountering an unusual issue and I’m unsure whether it’s related to Postman, SQL Server, or NodeJS. I am submitting a date in JSON format as follows: “DOB”: “01/01/1990”. However, the date stored in SQL Server appears as 1989-12-31 18:30:00.000. I would greatly appreciate any insights into this problem, as I have been unable to identify the underlying cause or a viable solution. I am using the datetime datatype in SQL Server to capture this input. The discrepancy is 5 hours and 30 minutes, corresponding to my current timezone. I have attempted using the datetimeoffset datatype and made efforts to convert the date to UTC using the moment library.
Ah, looks like a timezone conversion prob! When u use datetime in SQL Server, it’s not timezone aware. U can try printing/logging the date value right before you send it from Postman, maybe it’s being converted somewhere in your code n u didn’t notice? That might help!
From your description, it sounds like you’re dealing with a timezone issue when the data is being stored in SQL Server. Since you’ve noticed the discrepancy corresponds to your timezone, it appears that Postman sends the date in your local timezone, but SQL Server stores it as if it were in UTC. One approach is to ensure you convert the date to UTC before sending it to the server. You mentioned using the Moment library, which should help with this transformation. Prior to sending the date to Postman, convert it to a UTC timestamp in your backend code and then record it. This can help maintain consistency in your data handling process.