15,919,749 members
See more:
hi,
i have a datagrid in my proj that has a date field.
the problem is that i want to show the date at run time as dd/mm/yyyy and want to sort the date by month in ascending order.
if i take date formate as mm/dd/yyyy then the month is sorted perfectly but if i take dd/mm/yyyy formate then it sorts by day ie dd instead of month .
plz help me with the Query.
Posted

## Solution 3

Try:
SQL
`SELECT * FROM myTable ORDER BY Year(myDateColumn), Month(myDateColumn)`

Never try to sort only by the month: You need the year as well to be meaningfull.

Example given made no sense when I posted it... :doh: - OriginalGriff[/edit]

v2
Vandana87 13-Apr-11 6:40am
OriginalGriff 13-Apr-11 6:42am
You are welcome - but please DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.

## Solution 6

SQL
```SELECT tblBills.*,  MonthName(month(tblBills_1.Due_Date)) AS month1
FROM tblBills inner join tblBills AS tblBills_1
on tblBills.ID=tblBills_1.ID
order by tblBills_1.Due_Date```

try This code ,it will work!!

Vandana87 13-Apr-11 6:40am

## Solution 1

Click[^]

Vandana87 13-Apr-11 6:40am

## Solution 2

You can actually do a group by allowing you to do a sort by month.
See here[^] + this discussion here.

## Solution 4

SELECT * FROM myTable ORDER BY MyDatecolumn asc

## Solution 5

Why do you convert the date data into string before the sort? If you have the actual data in a date field, just use that in your `ORDER BY` clause:
`... ORDER BY DateField`

If you sort with partial date information the rows in the same month (or year unless you include that also) will be in 'random' order. I take it that is not what you want unless you have some other field you want to use for ordering within a month.