V
vbtoad
I am working with a database that stores dates in a number format.
This, of course, presents problems when attempting to query the data
on this field. For example, numbers like 110103 are considered
greater than 070104, when in fact it is an earlier date.
So...., I created a long formula that will convert the number to a
string (Cstr), extract the mm dd yy values from the string (Mid),
format the string with /'s (Format), convert the concatenated results
back to a date (CDate), and finally, format the date to a mm/dd/yyyy
value (Format).
Here is what the monster looks like -
EffDate: Format(CDate(Format(Mid(CStr(Format([caeffd],"000000")),1,2),"00\/")
& Format(Mid(CStr(Format([caeffd],"000000")),3,2),"00\/") &
Format(Mid(CStr(Format([caeffd],"000000")),5,2),"00")),"mm/dd/yyyy")
Now, my problem is this, when I attempt to query the results based on
this new 'date' field, I still am not picking up dates that are truly
earlier than the date entered, i.e. 11/01/2003 does not get returned
when asking for dates <= 07/26/2004.
The only thing I can think of is that I should break the formula out,
so that it is not converting a number to a string and then to a date
all at one time.
Is there any one out there who may have a solution to my dilemma?
TIA
David Tripp
This, of course, presents problems when attempting to query the data
on this field. For example, numbers like 110103 are considered
greater than 070104, when in fact it is an earlier date.
So...., I created a long formula that will convert the number to a
string (Cstr), extract the mm dd yy values from the string (Mid),
format the string with /'s (Format), convert the concatenated results
back to a date (CDate), and finally, format the date to a mm/dd/yyyy
value (Format).
Here is what the monster looks like -
EffDate: Format(CDate(Format(Mid(CStr(Format([caeffd],"000000")),1,2),"00\/")
& Format(Mid(CStr(Format([caeffd],"000000")),3,2),"00\/") &
Format(Mid(CStr(Format([caeffd],"000000")),5,2),"00")),"mm/dd/yyyy")
Now, my problem is this, when I attempt to query the results based on
this new 'date' field, I still am not picking up dates that are truly
earlier than the date entered, i.e. 11/01/2003 does not get returned
when asking for dates <= 07/26/2004.
The only thing I can think of is that I should break the formula out,
so that it is not converting a number to a string and then to a date
all at one time.
Is there any one out there who may have a solution to my dilemma?
TIA
David Tripp