From: robboll on
In trying to come up with a VBA timestamp for 2 digit year, month day
and 24 hr time, I came up with the following code. IT WORKS!

? mid(year(date()),3,2) & month(date())&day(date()) & replace
(FormatDateTime(Now, vbShortTime),":","")
0912291327

You can leave off the mid function if you want a full year. I just
thought the 2 digit year would suffice.

? year(date()) & month(date())&day(date()) & replace(FormatDateTime
(Now, vbShortTime),":","")
200912291339

While I was doing this I thought I'd try to scour the net to see if
there is a cleaner/sweeter way to do it.

Any suggestions out there?

RBollinger
From: Marshall Barton on
robboll wrote:

>In trying to come up with a VBA timestamp for 2 digit year, month day
>and 24 hr time, I came up with the following code. IT WORKS!
>
>? mid(year(date()),3,2) & month(date())&day(date()) & replace
>(FormatDateTime(Now, vbShortTime),":","")
>0912291327
>
>You can leave off the mid function if you want a full year. I just
>thought the 2 digit year would suffice.
>
>? year(date()) & month(date())&day(date()) & replace(FormatDateTime
>(Now, vbShortTime),":","")
>200912291339
>
>While I was doing this I thought I'd try to scour the net to see if
>there is a cleaner/sweeter way to do it.


IMO, that will not work for the first 9 days of any month
nor for the first 9 months in a year. E.g. 1 Jan 2010 will
come out as 10111327 and you'll never be able figure out
what is what without the month and day leading zeros.

It is way better to just leave the table field as a
Date/Time field and set it to Now. Then, whenever you want
to display it in a form or report for users that like seeing
that compressed style of timestamp, use a text box with
custom format of yymmddhhnn

--
Marsh
 | 
Pages: 1
Prev: exif
Next: Open an external file from a formular