How do I display time in gmt when my system clock is set to local

A

ai4gk

I have my Amateur Radio log in Excel, and likely will be converting it to
Access. My system clock is set to Eastern Time, changing between EST and EDT.
I need my entries to display in GMT (Greenwich Mean Time), which is fixed and
does not change with DST.
 
G

Gary''s Student

try this UDF:

Function gmt() As Date
Application.Volatile
dot = "."
Set Serve = GetObject("winmgmts:\\" & dot & "\root\cimv2")
Set Zones = Serve.ExecQuery("Select * From Win32_TimeZone")

For Each Zone In Zones
intTimeZoneBias = Zone.Bias
intDayLightBias = Zone.DaylightBias
Next

gmt = Now() - (intTimeZoneBias - intDayLightBias) / (60 * 24)

End Function
 
A

ai4gk

Okay. How do I plug that into the Excel sheet, and will that carry into
Access when I import it?

Thanks.
 
G

Gary''s Student

User Defined Functions (UDFs) are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the UDF will be saved with it.

To remove the UDF:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To use this UDF from Excel:

=gmt()

Like =SUM() or =AVERAGE(), but with no arguments

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

or

http://www.cpearson.com/excel/WritingFunctionsInVBA.aspx
for specifics on UDFs
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top