MSAccess - 时间戳 - 世界时?

时间:2013-08-16 16:00:39

标签: vba ms-access

我有一个在美国和印度时区本地共享并在本地运行的Access应用程序。我需要可靠地为记录更改添加时间戳。 User1和User2可能正在触摸时钟两侧的同一数据集中的记录。

用户将根据每个定期SYNC发送的Timestamp从SQL服务器推送/拉取带时间戳的记录。我做了一个初步的功能,只是抓住Now()值作为时间戳,但我可以看到这将是一个生产中的问题。

处理此时间戳的任何建议?

1 个答案:

答案 0 :(得分:0)

试试这个

Option Compare Database
Option Explicit

Private Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TimeZoneInfo) As Long


Private Type SystemTime
    intYear As Integer
    intMonth As Integer
    intwDayOfWeek As Integer
    intDay As Integer
    intHour As Integer
    intMinute As Integer
    intSecond As Integer
    intMilliseconds As Integer
End Type


Private Type TimeZoneInfo
    lngBias As Long
    intStandardName(32) As Integer
    intStandardDate As SystemTime
    intStandardBias As Long
    intDaylightName(32) As Integer
    intDaylightDate As SystemTime
    intDaylightBias As Long
End Type

Public Function GetUTCOffset() As Date
Dim lngRet As Long
Dim udtTZI As TimeZoneInfo

lngRet = GetTimeZoneInformation(udtTZI)
GetUTCOffset = udtTZI.lngBias / 60 / 24
End Function

我在这里找到了它:

http://www.dbforums.com/microsoft-access/1000377-now-users-using-different-time-zones.html