Date Format

Problem: I just want date – no time.
SQL statement:
SELECT SubjectIndex, LetterNo, DateOfIssue
FROM [CircularKeeper]
ORDER BY DateOfIssue DESC
After removing the time part I want it to be ordered descending.
I am binding the data using a SqlDataSource to a listsview and displaying the date in a label control.
You can do it a number of ways, in 2008 I’d go with:
As there is now a DATE data type – if you don’t actually store times in that field in the table, then you might want to consider changing the datatype from DATETIME to DATE instead – saves the CASTing like this and uses less space (3 bytes instead of 8).
You could also just do this in the UI by returning the DATETIME as you currently are, and making sure you format the dates appropriately before rendering.
Update:
I would recommend returning the DATE as a DATE from the query – so return the data in it’s strongly typed form. If for presentation purposes you need it formatted a certain way, I’d recommend applying the formatting in your presentation logic.