Moin zusammen,
ich möchte über eine Abfrage eine UTC-Zeit in eine CET-Zeit umwandeln.
Die Rohdaten sehen entweder so
20111206114952
oder
20.111.206.114.952
aus.
Das Ergebnis sollte dann ein normales CET-Format aufweisen, also:
06.12.2011 11:49:52
Kann mir hierzu jemand unter die Arme greifen?
Vielen Dank im Voraus
Andreas
Hallo,
das gibt eine lange Formel:
CETDatum: DatSeriell(Teil(Ersetzen([Rohdatum];".";"");1;4);Teil(Ersetzen([Rohdatum];".";"");5;2);Teil(Ersetzen([Rohdatum];".";"");7;2))+ZeitSeriell(Teil(Ersetzen([Rohdatum];".";"");9;2);Teil(Ersetzen([Rohdatum];".";"");11;2);Teil(Ersetzen([Rohdatum];".";"");13;2))
Übrigens hat das mit UTC und CET nichts zu tun. Beide Zeitformate sind je nach Land gleich, unterscheiden sich nur durch eine Zeitdifferenz von 2 Stunden. Dein Rohdatum ist sonst nicht als eine Folge von Zahlen (teilweise mit Punkt) die durch eine Formel in ein Zeitformat gebracht wird. Das dann erhaltene Format kann sowohl für UTC als auch CET zutreffend sein.
Moin MzKlMu,
ganz lieben Dank für die schnelle Hilfe, funktioniert hervorragend.
Sorry, die Überschrift ist korrekt gewesen, leider aber nicht die Beschreibung.
Leider habe ich in meiner Anfrage dies falsch beschrieben. Mir geht es tatsächlich um die reine Umwandlung, inklusive Zeitverschiebung.
Hier einmal ein korrektes Beispiel, diesmal auch nur ein Format :
20.111.205.234.812
Ergebnis:
06.12.2011 00:48:12
Sorry nochmals für die Verwirrungen.
Viele Grüße
Andreas
Hier mal ein Code welcher dir die UTC in die Locale Zeit umrechnet, wenn dein Rechner in CET läuft.
Die Funktion UTC2CurrentTZ baust du dann in deine Abfrage ein.
ergebnisse wären dann z.B.:
20.111.205.234.812 --> 06.12.2011 00:48:12
20.111.005.234.812 --> 06.10.2011 01:48:12
20.110.205.234.812 --> 06.02.2011 00:48:12
20.110.324.234.812 --> 25.03.2011 00:48:12
20.110.401.234.812 --> 02.04.2011 01:48:12
'// ----------------------------------------------------------------------------------------------------------------
'//
'// ----------------------------------------------------------------------------------------------------------------
Type sDate
sYear As String * 4
sMonth As String * 2
sDay As String * 2
sHour As String * 2
sMinute As String * 2
sSecond As String * 2
End Type
Type ssDate
sDate As String * 14
End Type
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
Type TIME_ZONE_INFORMATION
Bias As Long
StandardName As String * 64
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName As String * 64
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type
'// ----------------------------------------------------------------------------------------------------------------
'//
'// ----------------------------------------------------------------------------------------------------------------
Declare Function VariantTimeToSystemTime Lib "OLEAUT32.DLL" (ByVal vbtime As Double, lpSystemTime As SYSTEMTIME) As Long
Declare Function SystemTimeToVariantTime Lib "OLEAUT32.DLL" (lpSystemTime As SYSTEMTIME, vbtime As Double) As Long
Declare Function GetTimeZoneInformation Lib "KERNEL32.DLL" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
Declare Function SystemTimeToTzSpecificLocalTime Lib "KERNEL32.DLL" (lpTimeZoneInformation As TIME_ZONE_INFORMATION, lpUniversalTime As SYSTEMTIME, lpLocalTime As SYSTEMTIME) As Long
Function UTC2CurrentTZ(ByVal sDateUTC As String) As Date
Dim t As sDate
Dim u As ssDate
Dim d As Date
Dim dbl As Double
Dim tzi As TIME_ZONE_INFORMATION
Dim lst As SYSTEMTIME, ust As SYSTEMTIME
u.sDate = Replace(sDateUTC, ".", "")
LSet t = u
d = DateSerial(t.sYear, t.sMonth, t.sDay) + TimeSerial(t.sHour, t.sMinute, t.sSecond)
VariantTimeToSystemTime d, ust
If GetTimeZoneInformation(tzi) > 0 Then
SystemTimeToTzSpecificLocalTime tzi, ust, lst
SystemTimeToVariantTime lst, dbl
End If
UTC2CurrentTZ = dbl
End Function
:) :) :) :) :) DANKESCHÖN :) :) :) :) :)
für die schnelle Hilfe..........