
July 2nd, 2009, 02:57 PM
|
|
Registered User
|
|
Join Date: Jun 2009
Posts: 7
Time spent in forums: 2 h 16 m 5 sec
Reputation Power: 0
|
|
|
Dealing with Date in MSSQL Database
I'm building an archive of articles that I want to sort by date. Right now, I have added a column to each article's row in the database labeled Published. I'm not sure how to enter the date so that it would be able to be sorted as most recent. Right now, I have it entered in simple text in the format yyyymmdd.
So an article published on 3/31/2009 is entered as 20090331. When I query the database with this query:
Code:
SELECT TOP 5 Article_ID, Title, Article_Book FROM archive_content ORDER BY published DESC;
The articles are correctly sorted by most recent. Is this an appropriate way to handle the date, or is there something that I'm missing that would make this easier to deal with and avoid any issues that may appear with the format (for example, the month messing up the sorting of the articles)?
I also trying to display the date that each article was published, how can I change the variable Published back into mm/dd/yyyy format?
I feel like there is a simpler way to do this that would answer both questions at once, but I'm very new to asp and don't know how to do it. Thanks in advance for any help!
|