Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Order By day of week using Format(date, "w")

Status
Not open for further replies.

ejm8

Technical User
Apr 22, 2004
17
US
Hello,

I'm using an SQL string to populate a multiselect listbox with dates. It's something like this:

Code:
select job_date, format(job_date, "ddd") as Day from job_list;

...and I want to sort by Day of Week in order (i.e. Mon, Tue, Wed, Thu, Fri, Sat). So I tried this:

Code:
select job_date, format(job_date, "ddd") as Day from job_list order by format(job_date, "w");

...and I don't get any results. Any suggestions?

Thank you
 
I left out that I'm using "select DISTINCT".

When I copy the SQL string into a query, I get an error message saying "ORDER BY clause (format(job_date,"w")) conflicts with DISTINCT".

However, if I change it to "order by format(job_date,"ddd")" I don't get the error, BUT I also don't get the sort order I want.
 
Maybe:
[tt]SELECT DISTINCT job_date, Format(job_date,"ddd") AS [Day], Format(job_date,"w")
FROM statistics
ORDER BY Format(job_date,"w");[/tt]
 
That does it. Thank you Remou!

I just had to include the format(job_date,"w") in the select part as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top