A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Greenwich GMT Date and Time problem



 
 
Thread Tools Display Modes
  #1  
Old April 8th, 2009, 02:31 PM posted to microsoft.public.access.forms
gmazza
external usenet poster
 
Posts: 2
Default Greenwich GMT Date and Time problem

Hey there,
I have the following code in a module that I am calling the GetZuluTime() in
a text field on a form and my time is Mountain time, and its 4pm here now and
it is showing up as 10pm for some reason.
What I want is when a user NOT in my time zone uses this form, it needs to
record the time of their updates in a table. See anything wrong??

Private Const LOCALE_SYSTEM_DEFAULT& = &H800

'**********************************
'** Type Definitions:

Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type

Private Declare Sub GetSystemTime Lib "Kernel32" (lpSystemTime As SYSTEMTIME)

Private Declare Function GetTimeFormat& Lib "Kernel32" Alias _
"GetTimeFormatA" (ByVal Locale As Long, ByVal dwFlags As Long, _
lpTime As SYSTEMTIME, ByVal lpFormat As Long, _
ByVal lpTimeStr As String, ByVal cchTime As Long)

Public Function GetZuluTime() As Date

Dim myTime As SYSTEMTIME
Dim strBuffer As String
Dim lng As Long
Dim strSystemTime As String

GetSystemTime myTime
strBuffer = String$(255, Chr$(0))
lng = GetTimeFormat&(LOCALE_SYSTEM_DEFAULT, 0, myTime, _
0, strBuffer, 254)
With myTime
GetZuluTime = DateSerial(.wYear, .wMonth, .wDay) _
+ CDate(strBuffer)
End With

End Function

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200904/1

Ads
  #2  
Old April 9th, 2009, 01:54 PM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Greenwich GMT Date and Time problem

What's actually in strBuffer after your call to GetTimeFormat?

You might take a look at http://www.mvps.org/access/api/api0024.htm at "The
Access Web" to ensure you're also handling daylight savings time properly.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"gmazza" [email protected] wrote in message news:[email protected]
Hey there,
I have the following code in a module that I am calling the GetZuluTime()
in
a text field on a form and my time is Mountain time, and its 4pm here now
and
it is showing up as 10pm for some reason.
What I want is when a user NOT in my time zone uses this form, it needs to
record the time of their updates in a table. See anything wrong??

Private Const LOCALE_SYSTEM_DEFAULT& = &H800

'**********************************
'** Type Definitions:

Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type

Private Declare Sub GetSystemTime Lib "Kernel32" (lpSystemTime As
SYSTEMTIME)

Private Declare Function GetTimeFormat& Lib "Kernel32" Alias _
"GetTimeFormatA" (ByVal Locale As Long, ByVal dwFlags As Long, _
lpTime As SYSTEMTIME, ByVal lpFormat As Long, _
ByVal lpTimeStr As String, ByVal cchTime As Long)

Public Function GetZuluTime() As Date

Dim myTime As SYSTEMTIME
Dim strBuffer As String
Dim lng As Long
Dim strSystemTime As String

GetSystemTime myTime
strBuffer = String$(255, Chr$(0))
lng = GetTimeFormat&(LOCALE_SYSTEM_DEFAULT, 0, myTime, _
0, strBuffer, 254)
With myTime
GetZuluTime = DateSerial(.wYear, .wMonth, .wDay) _
+ CDate(strBuffer)
End With

End Function

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200904/1



  #3  
Old April 9th, 2009, 03:26 PM posted to microsoft.public.access.forms
gmazza via AccessMonster.com
external usenet poster
 
Posts: 177
Default Greenwich GMT Date and Time problem

Honestly, I used this code from an example on the forums that people said
worked. I just have it in a module, and I set up a text field and gave it a
source of =GetZuluTime() and its coming out with a time of 6 hours later.
I looked at the example you gave me the link to and Daylight Savings is a big
one. Where would I put that code, just in a module? How would I call it, or
display the actual time?
Thanks for your help!

Douglas J. Steele wrote:
What's actually in strBuffer after your call to GetTimeFormat?

You might take a look at http://www.mvps.org/access/api/api0024.htm at "The
Access Web" to ensure you're also handling daylight savings time properly.

Hey there,
I have the following code in a module that I am calling the GetZuluTime()

[quoted text clipped - 46 lines]

End Function


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200904/1

  #4  
Old April 9th, 2009, 10:26 PM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Greenwich GMT Date and Time problem

Terry's code isn't actually directly related to your question. Hopefully,
though, you can see from it how you'd adjust for daylight savings time.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"gmazza via AccessMonster.com" [email protected] wrote in message
news:[email protected]
Honestly, I used this code from an example on the forums that people said
worked. I just have it in a module, and I set up a text field and gave it
a
source of =GetZuluTime() and its coming out with a time of 6 hours later.
I looked at the example you gave me the link to and Daylight Savings is a
big
one. Where would I put that code, just in a module? How would I call it,
or
display the actual time?
Thanks for your help!

Douglas J. Steele wrote:
What's actually in strBuffer after your call to GetTimeFormat?

You might take a look at http://www.mvps.org/access/api/api0024.htm at
"The
Access Web" to ensure you're also handling daylight savings time properly.

Hey there,
I have the following code in a module that I am calling the
GetZuluTime()

[quoted text clipped - 46 lines]

End Function


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200904/1



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:36 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright 2004-2021 OfficeFrustration.
The comments are property of their posters.