2

Here is my query below. The problem im having is that B.REVISED_DATE is a string and B.REVISED_DATE a date and when i try to run the query, i get a data mismatch error. What i am trying to do is change B.REVISED_DATE into a string but I dont remember the exact syntax. I am using microsoft access as the database. Any help would be appreciated.

     SELECT A.ICAO, A.RWY, A.REVISED_DATE, B.REVISED_DATE
     FROM RUNWAYS A, RUNWAYS_UPDATABLE B, AIRPORT_CHECKLIST C
     WHERE A.RWYKEY = B.RWYKEY
     AND A.ICAO = C.ICAO
     AND A.REVISED_DATE <> B.REVISED_DATE
     AND TO_CHAR(B.REVISED_DATE) <> C.EMAIL_DATE
     ORDER BY A.ICAO
1
  • What format of string are you using for A.REVISED_DATE?. YYYYMMDD?, MM/DD/YYYY?, etc Commented Sep 12, 2011 at 19:55

2 Answers 2

4

Access' database engine doesn't support a TO_CHAR function.

If B.REVISED_DATE is Date/Time data type and C.EMAIL_DATE is text, you can use CDate() to get a Date/Time value from C.EMAIL_DATE.

B.REVISED_DATE <> CDate(C.EMAIL_DATE)

If you prefer to use the text equivalent of B.REVISED_DATE, you could use the CStr() function. However, unless it is formatted the same as C.EMAIL_DATE, your inequality comparison could be troublesome. You might be better off using Format() so that REVISED_DATE is formatted the same as EMAIL_DATE

Format(B.REVISED_DATE, "mm/dd/yyyy") <> CDate(C.EMAIL_DATE)

But seems simpler to me to do the comparison with both as dates, so you needn't be concerned about formatting issues.

Sign up to request clarification or add additional context in comments.

Comments

1

If you are looking to turn B.Revised_Date into a string use the Format() function.

Format(B.Revised_Date, "Format of date here")

Format will convert you date into whatever format you would like to use as shown here

If you are looking to turn B.Revised_Date into a Date use the CDate() function.

CDate(B.Revised_Date)

So if you are looking to have both of your dates be text then you can do something along these lines.

AND Format(A.REVISED_DATE, "MM/dd/yyyy") <> Format(B.REVISED_DATE, "MM/dd/yyyy")

Or however you want your dates to be formatted.

Hope this helps!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.