M
Mimo
Hi,
I have 2 fields from two tables that store dates as text formats.
I am trying to compare them using an iif statement along with the CDate
function.
Table 1 stores the date as mm/dd/yyyy hh:mm:ss and Table 2 stores the date
as yyyy-mm-dd h:mm:ss.
An example:
T1 .Date 1 T2 .Date.1
Equal
4/24/2002 0:00:00 2002-04-24 00:00:00 True
4/7/2001 0:00:00 2001-04-07 00:00:00 False
5/16/2005 0:00:00 2005-05-16 00:00:00 True
I have been using iif(Not(IsNull(T1.Date1)) And Not(IsNull(T2.Date2)),
iif(CDate(T1.Date1)<> CDate(T2.Date2)),"False","True"),"T")
So far it has been going well, but I noticed that though I could tell the
dates matched, False was being returned. The False in the example should be
true. I broke it down to see what was being returned by CDate(). T1.Date1
were all being evaluated correctly (dd/mm/yyyy), however CDate would evaluate
T2.Date2 as dd/mm/yyyy for records, it is evaluating to mm/dd/yyyy. This only
happens for the dates where both the day and month are less than 13.
What can I do to make sure that all equal dates are evaluated to true?
Thanx
I have 2 fields from two tables that store dates as text formats.
I am trying to compare them using an iif statement along with the CDate
function.
Table 1 stores the date as mm/dd/yyyy hh:mm:ss and Table 2 stores the date
as yyyy-mm-dd h:mm:ss.
An example:
T1 .Date 1 T2 .Date.1
Equal
4/24/2002 0:00:00 2002-04-24 00:00:00 True
4/7/2001 0:00:00 2001-04-07 00:00:00 False
5/16/2005 0:00:00 2005-05-16 00:00:00 True
I have been using iif(Not(IsNull(T1.Date1)) And Not(IsNull(T2.Date2)),
iif(CDate(T1.Date1)<> CDate(T2.Date2)),"False","True"),"T")
So far it has been going well, but I noticed that though I could tell the
dates matched, False was being returned. The False in the example should be
true. I broke it down to see what was being returned by CDate(). T1.Date1
were all being evaluated correctly (dd/mm/yyyy), however CDate would evaluate
T2.Date2 as dd/mm/yyyy for records, it is evaluating to mm/dd/yyyy. This only
happens for the dates where both the day and month are less than 13.
What can I do to make sure that all equal dates are evaluated to true?
Thanx