Avatar of timberadmin
timberadmin
Flag for Canada asked on

Excel datetime formatting UTC

Hi Experts,

In VBA, I am having trouble formatting a date/time into this UTC format like this: 2018-03-11T00:01:00Z

Please help...
Visual Basic.NETVBAMicrosoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Bill Prew

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Bill Prew

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Shaun Vermaak

You cannot just reformat it, it is a date offset
Set dateTime = CreateObject("WbemScripting.SWbemDateTime")    
dateTime.SetVarDate (now())
wscript.echo  "Local Time:  " & dateTime
wscript.echo  "UTC Time: " & dateTime.GetVarDate (false)

Open in new window

https://stackoverflow.com/questions/15887700/utc-time-assignment-in-vbscript
Bill Prew

Shaun,

That's not really true.  There are different formats for "UTC" time, see below link, specifically:

1994-11-05T08:15:30-05:00 corresponds to November 5, 1994, 8:15:30 am, US Eastern Standard Time.
1994-11-05T13:15:30Z corresponds to the same instant.
Date and Time Formats

This question didn't ask for info on calculating certain UTC values, rather just formatting a datetime value that had already been established...


»bp
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy