Solved

Wrong time in GI because of Daylight saving time

  • 31 August 2022
  • 7 replies
  • 279 views

Userlevel 1
Badge

I need to display on a custom GI the start and end log TIME
(from the Appointment screen FS300200).

As date-time fields are stored in UTC format.
Therefore I use the next well known approach to calculate hour’s part into local time zone:

Hour (
DateAdd (
[FSLog.DateTimeBegin],
'h',
DateDiff (
'h',
NowUTC(),
Now()
)
)
)

 

But, the problem.

How to manage winter/summer saving time periods?

The customer is from Singapore, and Singapore doesn't have saving time period.
With this Now/NowUTC approach for records from winter period a time is provided with one extra hour.

icon

Best answer by olexandrProkopovych94 6 September 2022, 18:14

View original

7 replies

Userlevel 7
Badge +16

Hi @olexandrProkopovych94 

Not sure if this may help or not, but what is in the Daylight Savings Settings in Acumatica? Is something manually configured?

 

 

Userlevel 1
Badge

@kbeatty21 , no, this is not the issue for this case.

But your advice helped me to solve another similar issue.
We tested GIs on different servers, and different sites had different time settings.
But we did not pay enough attention to this.

Badge +11

@olexandrProkopovych94

If I understand your problem, you’d like the time to be one hour different depending upon which month(s) the date falls in.

You could check the month of the current day and add (or subtract) one hour based on what month it falls in.

For instance: 

Hour(
IIf(
Month([dateField])>10 Or Month([dateField])<3,
DateAdd([dateTimeBegin],'h',DateDiff('h',NowUTC(),Now())),
DateAdd([dateTimeBegin],'h',DateDiff('h',NowUTC()+1,Now()))
)
)

The IF statement will check if the month number is greater or less than a certain amount and perform a different calculation depending upon that.

Userlevel 7
Badge +16

@kbeatty21 , no, this is not the issue for this case.

But your advice helped me to solve another similar issue.
We tested GIs on different servers, and different sites had different time settings.
But we did not pay enough attention to this.

With regards to your different times on different sites, have you checked the Site Preferences? The Login Time Zone drives that:

 

Userlevel 1
Badge

With regards to your different times on different sites, have you checked the Site Preferences?

Yes, this was the point. But not of the instance itself – of instance server.

Userlevel 1
Badge

What the lessons I’ve learned with this case.
Under server I’ll mean server or local PC where the instance is installed for developing or testing.

  1. Now() and NowUTC() functions utilize time of instance’s server, wherever it stands.
  2. Check time and time settings of your server. As well of your PC, if you access server remotely.
  3. GMT shifts may have same hours shift but different settings. E. g. the same GMT+X time zones may have different parameters for daylight savings time. Also, time zones settings may differ between different application (e.g. Acumatica and server’s OS). Might be surprises.
  4. Check time settings for the site and your user.
  5. Acumatica stores date/time fields in UTC. But may show converted to time zone of the server.
  6. When you enter in GI only the field (like [CRActivity.StartDate]) Acumatica will display it value converted to server time zone. But if you use the field in calculations, right, Acumatica use the value as it was stored (i.e. in UTC).
  7. Gratitude to @hkabiri for a trick how to display date/time as stored in DB. I mean expression =CDate([CRActivity.StartDate]).

 

Final advice. When you work with time and correct time is essential, use at least two columns “as is” (i.e. just [CRActivity.StartDate]) and “as stored” (i.e. =CDate([CRActivity.StartDate]) ). If you catch a doubt, you can compare values. After testing you may delete (or better de-activate) “as stored“ column.

Userlevel 7
Badge +16

@olexandrProkopovych94 

Thank you for the update!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved