Guys, need some help this is my code

    Select * Table1 ORDER BY Date DESC

My problem is I code in descending order but its not descending order because I try to add a Data instead of
5/6/2013 is the first item that i will see. 1/1/2012 can be appear.

Sorry for my english..

Recommended Answers

All 5 Replies

If the order is

5/6/2013
1/1/2012

That is in descending order.

if you want

1/1/2012
5/6/2013

Then you want ascending order, not descending.

what database are you using? you should be carefull with reserved word. I'm afraid that date is reserved word. I suggest changing field name, with something save like dt_input, or date_birth, etc. and something off with your query, it miss the from keyword.
try putting bracket like this

select * from table1 order by [date] desc (if you are using SQL Server)

I solved this problem thanks guys for the help.

@ricky
yeah when you use sql server you may need be carefull with your field name.
I try to convert my data type then it works.
from varchar to datetime

I thought it was already date type, not varchar. That makes more sense why it didn't work. As varchar the dates are parsed from left to right just like any other ordinary string. So 5/1/2013 is parsed differently from 05/01/2013 or 5/1/13. To parse varchar like date the string must be in YYYYMMDD or YYYY-MM-DD format. This is also true of file names -- if your program creates file names based on date and you want the files to appear in ascending order then the file names must be in YYYYMMDD format, otherwise they will not be sorted correctly.

Sorry, sir thats why I set up varchar into my field DATE because i want to add into my database is this format 5/6/2013. Then when I'm apply the datetime data type this is the format when I add
5/6/2013 12:00:00 AM, so when i call mt data in database can be appear all of that so thats why I changed the data type to solve my problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.