Solved

Convert a value to DateTime is off by a day

  • 1 February 2024
  • 3 replies
  • 54 views

Userlevel 1
Badge +5

I have a workflow in Nintex Automation Cloud that uses “Convert a value” to convert Text variable to DateTime variable but the date is off by 1 day -

 

Example: if the input is this,

2/6/2024

the output is this,

2/5/2024 18:00:00 PM

 

The “Convert a value” parameters look like this:

Source value = (a Text variable)

Target type = DateTime

Source dateTime format = M/d/yyyy

Source locale = United States (en-Us)

Result = (a DateTime variable)


Also, the Timezone settings in the workflow are:

Box checked for “Use the tenant’s default regional settings for this workflow” where Tenant default time zone is (UTC-06:00/UTC-05:00) America/Chicago.

 

icon

Best answer by bsikes 1 February 2024, 23:35

View original

3 replies

Userlevel 4
Badge +10

My assumption would be that it’s taking the string “2/6/2024”, and converting that to the date/time of 02/06/2024 00:00:00. Then, it’s adjusting for the time zone you set (-6 hours from UTC), resulting in 02/05/2024 18:00:00

Userlevel 1
Badge +5

Yes, that’s it!

 

I tested something out.  

I changed the workflow settings to use no timezone offset (make it GMT).  So "2/6/2024" converts to a DateTime of 2/6/2024 at midnight.  That's better.  But I don't want task escalation emails to be sent out at midnight.  So I need to append a time to that string before I convert to DateTime.  That STILL causes a timezone offset issue because when I get the current time of the workflow it is for my local time.

 

I’m working on a few different workarounds.  There’s no easy solution but we’ll figure something out.  Thanks.

Userlevel 4
Badge +10

In some of my workflows that have a timing aspect to it, I have a variable that contains the number of hours needed to adjust a time to the expected time zone. After I have the string converted to a datetime variable, I use the “Add time to date” action to add the “hours” variable to the converted variable to get the correct time.  Mainly, this is to make it easier to account for silly things like daylight savings time.

Reply