Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > Oracle
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 21st, 2006, 01:13 PM
Registered User
Join Date: Apr 2006
Location: los angeles, ca, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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



The dates are to be compared and then get the records with the highest or latest date value.


I have this code but I am trying to figure out what it all means.

I have several questions.
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?
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:


                      WHEN INSTR(TABCASER1.CASER_no,'-ERNIE') > 0 THEN

                      WHEN INSTR(TABCASER1.CASER_no,'-MONIE') > 0 THEN

                      WHEN INSTR(TABCASER1.CASER_no,'-NADINE') > 0 THEN


          between TO_DATE('#dateformat(form.startDate,"mm/dd/yyyy")#','MM/DD/YYYY') and TO_DATE('#dateformat(form.endDate,"mm/dd/yyyy")#','MM/DD/YYYY')

  #2 (permalink)  
Old July 24th, 2006, 04:58 PM
Registered User
Join Date: Jul 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts


I'm not sure I can answer your question completely, but I can offer a little wisdom:
1. 'GREATEST' is used for comparison, although I'm not sure how well it would work with date parameters. In order to get the greatest date, you may have to do some parsing of the date to strip out the day and month so you could get the highest day from the highest month
2. The TO_DATE function converts a string to a date in the supplied format string - in this case 'MM/DD/YYYY'. It ensures that apples are being compared to apples, as some systems might record May as '5', and others as '05'. For data integrity, is it necessary.
3. 'DECODE' is a sort of if-then-else statement. You can find a good explanation of this and other statements at
As far as the code itelf goes, it seems as though there is probably a better way to do it, but I would have to think it through. Also, the number of parameters in the DECODE statement seem to be a little off... I hope this helps.


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.Net - Access DB - Date compare johneecc VB How-To 4 August 7th, 2008 04:23 PM
compare Neha XSLT 6 July 24th, 2008 08:11 AM
compare nmnm XSLT 3 April 24th, 2007 08:13 AM
Compare two fields from different tables pallone SQL Server 2000 10 March 23rd, 2007 05:14 PM
Compare only the date portion of a datetime field CricketMaster Access 6 April 27th, 2005 01:06 AM

All times are GMT -4. The time now is 10:21 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.