90
Views
7
Comments
Solved
DateTime to UTC doesn't always happen
Application Type
Reactive
Service Studio Version
11.54.66 (Build 63364)

I have a weird case where my datetime from the client doesn't always convert to UTC on the server.

For example i select in the client the date 03/07/2024 08:00 (Lisbon time),  when i receive this attribute in the server action its changed to UTC 03/07/2024 07:00 as expected.

But... sometimes this doesn't happen and i can't understand why. Sometimes i receive the exact datetime that i selected in the client and its stored with that value in the database. Not in UTC.

I can't replicate this but i have multiple cases stored in the database where this happen, this also happen while debugging.

Note: This date is selected in the client and never changes until its saved in the DB.

Anyone else had this problem? Is this a bug?

UserImage.jpg
Miguel Barata
Solution

Problem found.

Server takes into account the datetime received and converts to UTC based on that date. That's ok, but if i try to create a date in the future where the daylight saving is the same as the server it doesn't convert as expected. 

This creates a problem with the following example:

Date range to create - 30/10/2024 9:00 until 30/10/2024 17:45

Date range already in the database - 30/10/2024 17:00 until 30/10/2024 19:00

Since the datetime Date range to create is already in a moment in time where Lisbon time is +0 it doesn't remove 1 hour and this creates a problem with the Date range already in the database because they intercept.

Its not an error but a detail that's needed to be taken into account.

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi @Miguel Barata ,

Maybe just daylight savings time.  Portugal is UTC + 0 for part of the year.

Dorine

UserImage.jpg
Miguel Barata

Yes but all records were created last week/this week, its +1

UserImage.jpg
Miguel Barata
Solution

Problem found.

Server takes into account the datetime received and converts to UTC based on that date. That's ok, but if i try to create a date in the future where the daylight saving is the same as the server it doesn't convert as expected. 

This creates a problem with the following example:

Date range to create - 30/10/2024 9:00 until 30/10/2024 17:45

Date range already in the database - 30/10/2024 17:00 until 30/10/2024 19:00

Since the datetime Date range to create is already in a moment in time where Lisbon time is +0 it doesn't remove 1 hour and this creates a problem with the Date range already in the database because they intercept.

Its not an error but a detail that's needed to be taken into account.

UserImage.jpg
vikas sharma
Champion

Hi,

Here want to add one more point about this conversion :

When we save date time in the database, it will be auto convert in UTC and vice versa. But it will not happen if you are using only Date or Time, auto conversion only work for datetime.

regards

UserImage.jpg
Miguel Barata

Yes, im using date time type, not date and time separated

2025-01-15 08-35-04
Vignesh Sekar

Dear Migual,

We already have a solution/forge component for your issue

Link


Please refer the link



UserImage.jpg
Miguel Barata

Update

Was able to reproduce it again and took some SS while debugging.

Note: date and time pickers are separated in the client but i do a build date time in the client action before sending to the server.

Ex1:

date time received in the input of the SA in UTC (correct)

Ex2:

date time received in the input of the SA (incorrect)


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.