[AccessD] UNIX time. Was: Crack Code

Stuart McLachlan stuart at lexacorp.com.pg
Fri Mar 23 18:52:31 CDT 2007


On 23 Mar 2007 at 17:23, Mark A Matte wrote:

> Function DeCode(OBJID As String)
> Dim P_One
...
> P_One = Left(OBJID, 1)
...
> P_One = DLookup("[Val] ", "tblKey", "[char]= '" & P_One & "'")
...
> P_One = P_One * 60466176
...
> DeCode = DateAdd("s", (P_One + P_Two + P_Three + P_Four + P_Five + P_Six),
> #12/31/69 4:00:00 PM#)
> 
> End Function
> 
> Any better ideas...please let me know.

Lose all the DLookups and use a loop :-)

Function Decode2(OBJID As String) As Date
Dim lngSeconds As Long
Dim strValues As String
Dim lngLoop As Long

strValues = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"

For lngLoop = 1 To 6
    lngSeconds = lngSeconds + _
    (InStr(strValues, Mid$(OBJID, lngLoop, 1)) * 36 ^ (6 - lngLoop))
Next
Decode2 = DateAdd("s", lngSeconds, #12/31/1969 4:00:00 PM#)
End Function
-- 
Stuart





More information about the AccessD mailing list