Date Format

T

Tom

I use a bound textbox (date field) into which today's date
is automatically entered when a record is created.

This is done via a small function in the BeforeInsert
event procedure.

Private Sub Form_BeforeInsert(Cancel As Integer)
Me![DATE] = Now()
End Sub

Until this point everything is fine....

Now the small problem. Although I specify a YYYYMM format
on the form (so it shows 200308), when I click on the
actual date field, it shows the long date format:
08/21/2003 11:57:59 AM

Again, I can overcome this in forms and reports, but I
need to concatenate this YYYYMM value with a monthly
serial number so that each record can be easily referenced
as i.e. 200308-0001, or 200308-0002, etc.

Currently, when concatenating the 2 fields, I get this
format in a query...
08/21/2003 11:57:59 AM 01
or
08/21/2003 11:57:59 AM 02


Is there a way to fix the date format and autonumber
format in query view as well?


Thanks,
Tom
 
D

Dale Fye

Use the Format() function. Something like the following should work.

Format([Date], "YYYYMM") & "-" & FORMAT([MonthlySerial], "0000")

--
HTH

Dale Fye


I use a bound textbox (date field) into which today's date
is automatically entered when a record is created.

This is done via a small function in the BeforeInsert
event procedure.

Private Sub Form_BeforeInsert(Cancel As Integer)
Me![DATE] = Now()
End Sub

Until this point everything is fine....

Now the small problem. Although I specify a YYYYMM format
on the form (so it shows 200308), when I click on the
actual date field, it shows the long date format:
08/21/2003 11:57:59 AM

Again, I can overcome this in forms and reports, but I
need to concatenate this YYYYMM value with a monthly
serial number so that each record can be easily referenced
as i.e. 200308-0001, or 200308-0002, etc.

Currently, when concatenating the 2 fields, I get this
format in a query...
08/21/2003 11:57:59 AM 01
or
08/21/2003 11:57:59 AM 02


Is there a way to fix the date format and autonumber
format in query view as well?


Thanks,
Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top