|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Compare Date fields and Display
Hi Frnds,
It will of great gesture if anyone can help me out. Take two dates(date1, date 2) as an input, compare them Get the number of days between the two dates. If Date 1> Date 2 display Date 1 If Date 1=Date 2 display Date1 and Date2 If Date 1< Date 2 display Date 2. Cheers!!! Suhan |
|
#2
|
||||
|
||||
|
Is this SQL, or a stored procedure?
|
|
#3
|
|||
|
|||
|
Try this:
Code:
SELECT DATEDIFF(dd,date1,date2) AS days_no ,CASE WHEN date1 > date2 THEN date1 WHEN date1 = date2 THEN CONCATENATE(date1 || date2) WHEN date1 < date2 THEN date2 END AS display_date FROM table Syntax for DATEDIFF and CONCATENATE may vary slightly depending on your exact brand, but you should be able to use something close to the above.
__________________
"A pawn is the most important piece on the chessboard -- to a pawn" |
![]() |
| Viewing: Dev Articles Community Forums > Databases > General SQL Development > Compare Date fields and Display |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|