Your database have datetime field CreatedOn
DESC- Descending Order
ASC - Ascending Order.
MSSQL Query
select * from tablename ORDER BY CONVERT(datetime, CreatedOn) DESC;
select * from tablename ORDER BY CONVERT(datetime, CreatedOn) ASC;
For cheking Condition
select * from tablename where Status = 1 ORDER BY CASE WHEN (CONVERT(date, ClosedDae) <= GetDate())THEN 1 ELSE 0 END ASC;
DESC- Descending Order
ASC - Ascending Order.
MSSQL Query
select * from tablename ORDER BY CONVERT(datetime, CreatedOn) DESC;
select * from tablename ORDER BY CONVERT(datetime, CreatedOn) ASC;
For cheking Condition
select * from tablename where Status = 1 ORDER BY CASE WHEN (CONVERT(date, ClosedDae) <= GetDate())THEN 1 ELSE 0 END ASC;
No comments:
Post a Comment