It seems like the database has weird behavior with hours. I have a column Time_ce of type Datetime, and a generated column that take the hour and minute of Time_ce. However, the generated column always show one hour less than the actual time in Timce_ce.
Here are the calculations of the the generated column (to make them show two digits always):
Concat(case when hour(Time_ce) in (0,1,2,3,4,5,6,7,8,9) then concat(“0”,hour(Time_ce))
else hour(Time_ce) end,“:”,case when minute(Time_ce) in (0,1,2,3,4,5,6,7,8,9) then concat(“0”,minute(Time_ce))else minute(Time_ce) end)
I have also created an API to update datetime, the updated time also always has one hour of difference with the time I entered with API. Why is this happening?
I see…Then how can I make it as it is without the auto transformation? My users are from different time zones and they can submit date themselves for other users in the same time zone.
For example user A submits 12/31/2020 08:00:00, I want the Time_ce variable to have 12/31/2020 08:00:00 and the HourSimple function to extract 08:00 as intended, because I need to display it to other users in the same area as A. If they transform the time zone automatically for it will be misleading for users. Is there any way to do this? Thanks!
You should change the time on the client side. Server store all dates in UTC(GMT-0) zone, so you write the code on the client side which check what is current time zone and add or subtract hours. For example you client has timezone GMT+2, so you get date from server and add 2 hours