Regrouping Split Date Values

MsfStl

Registered User.
Local time
Today, 09:55
Joined
Aug 31, 2004
Messages
74
Hello,

I have an Access table and form that has the Date split into three variables one for month, day and year respectively. How can I rejoin these three variables as a singular date? Additionally, can I do it via code. Nothing I sem to do works I have tried to concatenate the three into one variable and then reformat that variable, but Access barks that it is not the correct format (duh). Any ideas would be appreciated.

MsfStl
 
Hi -
You can use the dateserial() function to populate a date field. For example, if you had three numerical fields (yrz, moz, daz) which you need to reconstitute into a single date field (mydate), you could use an update query similar to this:
Code:
UPDATE tblErrorFix SET tblErrorFix.mydate = DateSerial([yrz],[moz],[daz])
WHERE ((Not (tblErrorFix.daz) Is Null));
HTH - Bob
 
As raskew, very astutely said.

Also, just for the record, you could use CDate().

If you join the 3 values into a string, then Cdate(), will convert it to a Date, data type.

Dim dteDate As Date

dteDate = CDate(Me.txtMonth & "/" & Me.txtDay & "/" & Me.txtYear)
 
But remember that Cdate works with Local dates so in the UK
Cdate("1/11/2005") will return 1 Nov

HTH

Peter
 

Users who are viewing this thread

Back
Top Bottom