Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In Access 97can I combine three date fields into one field? 1

Status
Not open for further replies.

Cowboysooner

Technical User
Oct 2, 2001
19
US
My query calculates due dates and must use three fields due to the large size of the formulas. Consolidating the formulas to one or two fields results in a "too complex" error message.

I would like to combine the results of the three fields into a single field. The formula output for each field is either a date or Null.

CDate([Field1]) correctly displays the date, but

CDate([Field1]) Or CDate([Field2]) does not work.


 
Here's a very simplistic, but working, approach using the switch() function.

Given three date fields, Field1, Field2 and Field3, and that one will contain a date and two will not:

SELECT tblDateFields.Field1, tblDateFields.Field2, tblDateFields.Field3, Switch(IsDate([Field1]),[Field1], IsDate([Field2]),[Field2], IsDate([Field3]), [Field3]) AS MyDate
FROM tblDateFields;
 
Works great. I was able to combine columns using IIF but your method is much easier. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top