I've been kicking this dead horse and I can't seem to see why nobody else sees this issue in their applications.
But, the StrToVBDate function that's been posted here quite a bit is apparantly not working.
I fed it THIS NIST time (as logged when retrieved):
(Been testing as you can see)
51930 01-01-21 15:39:16 00 0 0 584.8 UTC(NIST) *
51930 01-01-21 15:46:06 00 0 0 978.7 UTC(NIST) *
51930 01-01-21 15:46:16 00 0 0 102.5 UTC(NIST) *
51930 01-01-21 15:46:19 00 0 0 454.8 UTC(NIST) *
Now, notice the year!!! Notice where it's at? This does not seem right...
One would EXPECT it on the right hand side:
01-21-01 but Windows does soemthing weird with thsi, so my remedy is below and it NOW WORKS!!
------------------
Scott
mailto:[email protected][email protected]</A>
But, the StrToVBDate function that's been posted here quite a bit is apparantly not working.
I fed it THIS NIST time (as logged when retrieved):
(Been testing as you can see)
51930 01-01-21 15:39:16 00 0 0 584.8 UTC(NIST) *
51930 01-01-21 15:46:06 00 0 0 978.7 UTC(NIST) *
51930 01-01-21 15:46:16 00 0 0 102.5 UTC(NIST) *
51930 01-01-21 15:46:19 00 0 0 454.8 UTC(NIST) *
Now, notice the year!!! Notice where it's at? This does not seem right...
One would EXPECT it on the right hand side:
01-21-01 but Windows does soemthing weird with thsi, so my remedy is below and it NOW WORKS!!
Code:
Function StrToVbDate(ByVal dt As String) Export As Double Local x As Long Local y As String Local vbdate As Double Local lResult As Long Local stDay As String Local styear As String ' 01-01-21 stday = Mid$(dt,4,2) stYear = Mid$(dt,7,2) 'Swap the day and the year from NIST time: Problem solved here Mid$(dt,7,2) = stday Mid$(dt,4,2) = styear dt = uString(dt) ' If IsFalse(VarDateFromStr(ByVal StrPtr(dt), %LOCALE_USER_DEFAULT, %LOCALE_NOUSEROVERRIDE, vbdate)) Then lResult = VarDateFromStr(ByVal StrPtr(dt),0, 0, vbdate) Select Case lResult Case %FALSE Function = vbdate Case %DISP_E_TYPEMISMATCH 'Can't convert string to date, set 0 and invalidate Function = %FALSE Case %DISP_E_OVERFLOW Function = -1 Case %E_OUTOFMEMORY 'Throw exception here Function = %FALSE End Select End Function
Scott
mailto:[email protected][email protected]</A>
Comment