Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Community is experiencing an influx of spam. As we work toward a solution, please use the 'Notify Moderator' option on the ellipsis menu to flag inappropriate posts.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Convert DateTimeNow to GMT

Apcvirgo1
7 - Meteor

Is there a tool that converts DateTimeNow to GMT time zone while taking into consideration DST changes?

5 REPLIES 5
DataNath
17 - Castor
17 - Castor

Hey @Apcvirgo1, as GMT = UTC, you can wrap the DateTimeNow() function in the DateTimeToUTC() function which will convert your local system time to UTC. That said, UTC doesn't observe DST and so In order to account for this, I think you'd need to introduce a lookup table of dates as well as the time adjustments (+/- X hours), then use a Formula tool with an expression that adds that difference, using DateTimeAdd().

OllieClarke
15 - Aurora
15 - Aurora

Hi @Apcvirgo1 

DateTimeNow() uses the system date and time, you can use DateTimeToUTC(DateTimeNow()) to convert the system date to Coördinated Universal Time


The UK is on UTC between the last Sunday of October and the last Sunday of March. As these things are variable, there isn't an actual tool that can do this (other than maybe the python/R or run command tools). 

I've built this workflow which will output the current time in UK time - most of which is dynamically producing the change times for the current yearScreenshot 2023-06-30 at 16.18.22.png

 

Hope that helps,

 

Ollie

 

 

Apcvirgo1
7 - Meteor

Thank you @OllieClarke  for this. For some reason Formula14 is erroring due to the "between" - receiving Unknown function. Maybe it's the version we use here.  

OllieClarke
15 - Aurora
15 - Aurora

Hi @Apcvirgo1 

Yeah, the between() function was released in version 2023.1 I commented a version of the formula which doesn't use it, so delete the active formula and remove the "//" to use that version (also here)

IF DateTimeToUTC(datetimeNow())>=[Forward] AND  DateTimeToUTC(datetimeNow())<[Back]
THEN DateTimeAdd(DateTimeToUTC(dateTimeNow()),1,'hour')
ELSE DateTimeToUTC(dateTimeNow())
ENDIF

 

Apcvirgo1
7 - Meteor

@OllieClarke thanks again - this works well

Labels