Date Format

  • Thread starter Thread starter Anand
  • Start date Start date
A

Anand

Hello,
I am using an A2000 app. I am trying to create a table in
VB code with a date field (myDate). The default value
of myDate is set to a variable stAttDate which is a user
input. My code looks something like this:

Dim stAttDate As Date
Dim dbs As DAO.Database
Dim tbldef As TableDef

stAttDate = Me.ACalendar
Set dbs = CurrentDb
Set tbldef = dbs.CreateTableDef("tempAttendance")

With tbldef
..Fields.Append .CreateField("AttDate", dbDate)
End with
tbldef.Fields!AttDate.DefaultValue = stAttDate

The code works fine. Only the format of the date is
wrong. If the user enters 07-Sept-03 the default value
(in the myDate
field) turns into 09-July-03. I checked the code in break
mode and the date format of the stAttDate variable is
correct.

I cant seem to figure out how to get this right. Please
help.

Thanks in advance,
Anand
 
I assume that when you say they enter 07-Sept-03, you really mean they're
entering 07/09/2003, don't you?

Access will always assume that numeric dates are in mm/dd/yyyy format,
regardless of what the short date format has been set to, unless it's an
invalid date that way (such as 25/12/2003, since there's no month 25)

How to handle this depends on how you're accepting input. Check out Allen
Browne's "International Dates in Access" at
http://users.bigpond.net.au/abrowne1/ser-36.html for a good overview.
 
Back
Top