>You could convert to currency as the number of digits for the integer part of currency is 14.9649
>
>?log10($922337203685477)
>
>
>But that is also taking 8 bytes - as the DateTime field
Currency is a double integer and datetime is two integers. Now there's some waste in there, as the seconds are stored as milliseconds, but Fox had trouble with those (in VFP5 it was pretty much impossible to compare datetimes as one would contain milliseconds and the other wouldn't but they'd look the same until you calculate the difference between them) so nowadays milliseconds are not stored at all. So there are only 86400 values to store in an integer. Also, out of 0xffffffff available days, we're looking at a range of, say, a century at most (unless your app does archaeology or astronomy), so it's about 36000 days. So, assuming we're dealing only with this limited precision and range, here it is:
o=createobject("t2s")
lcD=o.t2s(datetime())
?lcD, o.s2t(lcd)
Define Class t2s As Custom
Name = "app"
starttime = { :}
trnN2S="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ()+-/#$%!"
Procedure Init
This.starttime=Datetime()
Procedure t2s(tt)
Local nDaynr, nSecs
nDaynr=Ttod(tt)-{^1980-01-01}
nSecs=Int(tt-Dtot(Ttod(tt)))
Return This.n2s(nDaynr)+"_"+This.n2s(nSecs,3)
Procedure s2t(c)
Local c, o, N, i, l, cCRS
cDate=Getwordnum(c,1,"_")
cTime=Getwordnum(c,2,"_")
dDate={^1980-01-01}+This.s2n(cDate)
tDt=Dtot(dDate)+This.s2n(cTime)
Return tDt
Procedure n2s(tNR, nLen)
Local nMod, numdat, sl
nMod=Len(This.trnN2S)
numdat=tNR
sl=""
Do While numdat>0
ns=numdat%nMod
sl=Substr(This.trnN2S,ns+1,1)+sl
numdat=Int(numdat/nMod)
Enddo
If !Empty(nLen) And Len(sl)<nLen
sl=Padl(sl, nLen, Left(This.trnN2S,1))
Endif
Retu sl
Procedure s2n(c)
Local nMod, N
nMod=Len(This.trnN2S)
N=0
For i= 1 To Len(c)
N = N*nMod+Atc(Substr(c, i, 1), This.trnN2S) -1
Endfor
Retu N
Enddefine
Adding more characters to the coding string may actually shorten the result even more - like adding lowercase, accented etc. Also, using fixed lengths for parts may remove the underscore (as the lengths of the date and seconds part will be known in advance). Initially, my coding string was much shorter, because I was also using this to generate filenames - had an old digital camera which didn't have continuous counting, so every time I wipe the card it starts from img_0001.jpg, but at least it stored the datetimes somewhere, so I dug that out and renamed the files as per those internal timestamps. The result had to conform to file naming conventions, so I couldn't add lowercase or punctuation to it - had just uppercase and digits, and the resulting string was, guess what, 8 bytes :). But at least it was printable.