remodeling a date

Bill Moore

Registered User.
Local time
Today, 20:02
Joined
Dec 11, 2003
Messages
51
I'm using the DatePart function to extract month, day, and year from a date/time data type date.

Question is: How do I extract these pieces and put them back together as a date/time expression so I don't get "data type mismatch" when trying a subsequent compare with another date? My expression looks like this:

Date1: DatePart("m", bcdate) & "/" & DatePart("d", bcdate) & "/" & DatePart ("yyyy", bcdate)

Thx.
 
Code:
DateSerial( Year, Month, Day)

However, wouldn't this just do what it appears you want?

Date1: Format(bcdate, "m/d/yyyy")
 
The Date1: Format (bcdate, "mm/dd/yyyy") worked fine. However, I still get a "data type mismatch" error when I try to compare Date1 with bcdate from another query. They look the same but obviously, they're not.

This is all part of a union query I'm doing where I need to exclude the "time" part of a Date/Time data type. In other words, a bcdate entered for one date in say 2004 needs to compare equal to a bcdate entered for one date in 2003 without regards to time (which could be different for each; even though the date parts are equal).

Thx.
 
You can also use the CDate() function.
 

Users who are viewing this thread

Back
Top Bottom