Null Date Question

J

John Lane

How can I union two queries, one with valid dates and the other with null
dates and not get a type mismatch error? If I make the null date field an
empty string (ie., ""), it unions, but the software turns the dates into
strings. I want to keep it date type so it can be sorted by date. Thanks.
 
M

MGFoster

John said:
How can I union two queries, one with valid dates and the other with null
dates and not get a type mismatch error? If I make the null date field an
empty string (ie., ""), it unions, but the software turns the dates into
strings. I want to keep it date type so it can be sorted by date. Thanks.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Put the query with the valid dates on top:

SELECT date_column, ...
FROM ...

UNION ALL

SELECT NULL_date_column, ...
FROM ...

This way the top date_column defines the output as a DateTime data type.
Of course, that column must really be defined as a DateTime data type!

HTH,
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSmRvr4echKqOuFEgEQKXyQCg5va14pvRKzUQ51p+SNaR/cAmsuoAoKZy
gfzIRXOi+iA0+eiPKq6OqD4T
=XKNK
-----END PGP SIGNATURE-----
 
J

John Lane

Here's what I did:

Did an IsDate, and if true, did a DateValue, if false, inseted Null. Works
great!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top