compare these date fields and compare and get the
I am trying to compare these date fields and compare and get the later date of the fields
Someone sent me this code.
Tables are
TABCASER
TABCASER1
EVCASERS
Field
Are
TABCASER1.CASER_no
The dates are to be compared and then get the records with the highest or latest date value.
TABCASER1.CASERRECIEVEDDATE
EVCASERS.FINALEVDATES
EVCASERS.PUBLICATIONDATE
EVCASERS.PUBLICATIONDATE
TABCASER.COMPAREACCEPDATE
I have this code but I am trying to figure out what it all means.
I have several questions.
1.
1. greatest it is used here to compare right? How do I then output this ? do I store it to a var (coldfusion) ultimately , I wish to send it to a page of records
2. is it necessary to use todate? And to_date? What does this do?
3. decode, is this necessary too. What does this do? NULL?
4.
5.
6. when I do get the query results how do I send it to coldsuion and out put to a display.
is there abetter way of doing this? To compare the dates and store in a var to display. thanks
Here is my code below:
Greatest(
CASE
WHEN INSTR(TABCASER1.CASER_no,'-CE') > 0 THEN
decode(TABCASER1.CASERRECIEVEDDATE,NULL,TO_DATE('0 1/01/1900','mm/dd/yyyy'),TABCASER1.CASERRECIEVEDDATE)
WHEN INSTR(TABCASER1.CASER_no,'-ERNIE') > 0 THEN
decode(EVCASERS.FINALEVDATES,NULL,TO_DATE('01/01/1900','mm/dd/yyyy'),EVCASERS.FINALEVDATES)
WHEN INSTR(TABCASER1.CASER_no,'-MONIE') > 0 THEN
decode(EVCASERS.PUBLICATIONDATE,NULL,TO_DATE('01/01/1900','mm/dd/yyyy'),EVCASERS.PUBLICATIONDATE)
WHEN INSTR(TABCASER1.CASER_no,'-NADINE') > 0 THEN
decode(EVCASERS.PUBLICATIONDATE,NULL,TO_DATE('01/01/1900','mm/dd/yyyy'),EVCASERS.PUBLICATIONDATE)
ELSE
decode(TABCASER.COMPAREACCEPDATE,NULL,TO_DATE('01/01/1900','mm/dd/yyyy'),TABCASER.COMPAREACCEPDATE)
END
,decode(TABCASER.COMPAREACCEPDATE,NULL,TO_DATE('01/01/1900','mm/dd/yyyy'),TABCASER.COMPAREACCEPDATE))
between TO_DATE('#dateformat(form.startDate,"mm/dd/yyyy")#','MM/DD/YYYY') and TO_DATE('#dateformat(form.endDate,"mm/dd/yyyy")#','MM/DD/YYYY')
susanring
|