<a href="http://itknowledgeexchange.techtarget.com/itanswers/find-sharp-days-between-2-dates-in-query-400/">This Answer may help</a>
==================================================
Unfortunately, that referenced answer doesn't address the question.
No, the startdate and enddate fields should be DATE or TIMESTAMP fields or be DATE expressions. You may convert various character fields into "dates" with a variety of functions.
Overall, you shouldn't be using Query/400 at all. Use Query Manager instead. See the STRQM command. (It might not be installed. SQL options are needed, though experience can show you how to create and use QM queries even without having the SQL options product installed.)
Tom
Last Wiki Answer Submitted: April 22, 2010 7:11 am by ITKE16,755 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
If the fields are defined as character then convert the date field to a YYYY-MM-DD format (include the – symbol) via a Define Result Fields as follows:
OLDESTCHR1 substr(chr1,1,4) || ‘-’ ||
substr(chr1,5,2) || ‘-’ ||
substr(chr1,7,2)
(change the start positions accordingly).
Do the above for both date fields.
DATECHRDIF date(OLDESTCHR2) –
date(OLDESTCHR1)
This will give you the number of days between two dates (0 days when dates are the same).
If the fields are already defined as date (in YYYY-MM-DD format) then the formula is as follows:
DATEDIFF DateField2 – DateField1
If the fields are defined as character then convert the date field to a YYYY-MM-DD format (include the – symbol) via a Define Result Fields as follows:
OLDESTCHR1 substr(chr1,1,4) || ‘-’ ||
substr(chr1,5,2) || ‘-’ ||
substr(chr1,7,2)
(change the start positions accordingly).
Do the above for both date fields.
DATECHRDIF date(OLDESTCHR2) –
date(OLDESTCHR1)
This will give you the number of days between two dates (0 days when dates are the same).
If the fields are already defined as date (in YYYY-MM-DD format) then the formula is as follows:
DATEDIFF DateField2 – DateField1