By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,198 Members | 961 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,198 IT Pros & Developers. It's quick & easy.

Time conversion

P: n/a
I'm a novice in this subject....I've made a database that requires a
time conversion. For example, if local time is 1200, determine the
time in Korea. I use two fields: a date field, and a time field. I
need the converted time to show up in a report. I also need the
corresponding date to increment if necessary. Any ideas on how to do
this would be greatly appreciated.
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The world is divided into different time zones (see the Map of time
zones, below). Each zone is designated X number of hours from
Greenwich Mean Time (or UTC: Universal Temp Coordination [Universal
Coordinated Time] - pardon my French). To get an accurate time of a
location in the world you'd have to convert your time to UTC (when
your time zone is negative, you'd have to ADD hours to UTC; when your
time zone is positive, you'd have to SUBTRACT hours from UTC.) then
add/subtract number of hours other location is from UTC.

Example (this doesn't include Day Light Savings Time [another can of
worms, since each country defines their own], see free time conversion
software, below):

Oakland time: 21 Nov 2003 1200.

Oakland is -8 UTC
Get UTC: 1200 + 8 = 2000 UTC

Korea is +9 UTC
Get Korea's time relative to previously calculated UTC:
2000 + 9 = 2900 = 1 day & 5 hrs or 22 Nov 2003 0500

===

Items from Google search on "time zone":

Map of time zones:
http://www.worldtimezone.com/

Free software to get time in different zones (untested):
http://www.timezonesforpcs.com/details.htm
Here is some VBA code I devised to get UTC.

== Begin Code ==

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 Sub GetLocalTime 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)

Sub ShowTime()

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

GetLocalTime myTime
strBuffer = String$(255, Chr$(0))
lng = GetTimeFormat&(LOCALE_SYSTEM_DEFAULT, 0, _
myTime, 0, strBuffer, 254)
Debug.Print "Local Time = "; strBuffer
With myTime
Debug.Print "Local Date = "; _
DateSerial(.wYear, .wMonth, .wDay)
End With

GetSystemTime myTime
strBuffer = String$(255, Chr$(0))
lng = GetTimeFormat&(LOCALE_SYSTEM_DEFAULT, 0, _
myTime, 0, strBuffer, 254)
Debug.Print "GMT Time = "; strBuffer
With myTime
Debug.Print "GMT Date = "; _
DateSerial(.wYear, .wMonth, .wDay)
End With

End Sub

== End Code ==

HTH,

MGFoster:::mgf
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP78Qk4echKqOuFEgEQJYbgCeLV+f5fbdUyBG+0iWf3cI3L d+XyYAoN+q
3CMpyI3yxEqOlGJtQu2rjes7
=yo22
-----END PGP SIGNATURE-----

heirou wrote:
I'm a novice in this subject....I've made a database that requires a
time conversion. For example, if local time is 1200, determine the
time in Korea. I use two fields: a date field, and a time field. I
need the converted time to show up in a report. I also need the
corresponding date to increment if necessary. Any ideas on how to do
this would be greatly appreciated.

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.