Time/Date Functions

  • Thread starter Thread starter Pamela via AccessMonster.com
  • Start date Start date
P

Pamela via AccessMonster.com

This is probably a simple question...all I want to do is to display the
current date & time (Now()), but just the numbers. For example, 01/01/2006
09:20:33 AM would be 01012006092033

Is there an existing function for this. I looked around a bit but didn't find
one that does this.

Thanks.
 
Pamela said:
This is probably a simple question...all I want to do is to display
the current date & time (Now()), but just the numbers. For example,
01/01/2006 09:20:33 AM would be 01012006092033

Is there an existing function for this. I looked around a bit but
didn't find one that does this.

Thanks.

Just use a format property of...

mmddyyyyhhnnss
 
Kewl! Found the Format function in MS Help after I posted.
Thanks!
strDateTime = Format(Now(), "mmddyyyyhhnnss") did the trick. :)

Still becoming familiar with VB functions.

Rick said:
This is probably a simple question...all I want to do is to display
the current date & time (Now()), but just the numbers. For example,
[quoted text clipped - 4 lines]

Just use a format property of...

mmddyyyyhhnnss
 
Pamela said:
Kewl! Found the Format function in MS Help after I posted.
Thanks!
strDateTime = Format(Now(), "mmddyyyyhhnnss") did the trick. :)

Still becoming familiar with VB functions.

There is a distinction that needs to be made here. What I suggested was
using the format *Property*. That gives you the desired display, but the
underlying data is still a date and it will be treated like a date for
sorting and comparisons.

The Format() *Function* which is what you used actually takes the date and
transforms it into a string in the output so now the field will act like a
string when it comes to sorting and comparisons. You have to take this
difference into account when you are choosing between the two methods.

Also, when using a format property the field will still be editable. If you
use the Format() function it will not be.
 
That's what I figured...

I knew how to use the format property for fields & controls on forms, it was
the VB code for converting a date & time I was looking for as I needed to use
it to append to the beginning of imported email attachment filenames to make
them unique. Your suggestion led me to look at using format in Visual Basic,
so thanks! :-)
 
Back
Top