I have a table with events with a column called Event Date.
I want to order it so that the Latest event date (closes to the current system date) is on top with the rest following underneath and then as soon as that date passed it should move to the bottom with the rest.
I don't know if there is a way to do what I want but I have searched the internet and I found a few things that might be what I am looking for but its not exactly working..
Here are some examples
SELECT * FROM events
ORDER BY EVENTDATE ASC,
CASE EVENTDATE WHEN 'future' THEN EVENTDATE END ASC,
CASE WHEN EVENTDATE <> 'future' THEN EVENTDATE END DESC
This one gave me an error : Conversion failed when converting date and/or time from character string.
Then I tried this:
SELECT *
FROM mtc3_doradosbc.cw_events
ORDER BY
CASE WHEN EVENTDATE > GETDATE().now THEN 1
WHEN EVENTDATE < GETDATE() THEN 2
END ASC,
EVENTDATE
and this
SELECT *, EVENTDATE(date, GETDATE()) FROM mtc3_doradosbc.cw_events
order by CASE WHEN mtc3_doradosbc.cw_events < 0 THEN 1 ELSE 0 END, diff
If any one could assist i would appreciate it greatly
Thank you
Example ( this is what i have)
Event 1 ----10 Mar 2014
Event 2 ----28 mar 2014
Event 25----25 Mar 2014
I want on the 25 Mar 2014
Event 25----25 Mar 2014
Event 2 ----28 mar 2014
Event 1 ----10 Mar 2014
I want on the 26 Mar 2014
Event 2 ----28 mar 2014
Event 25----25 Mar 2014
Event 1 ----10 Mar 2014