472,796 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,796 software developers and data experts.

Quick and simple way to order a set of meetings by day of week

Okay, I have a database listing various meetings. The meetings have a
day of the week and a time (Say Sunday at 8:00). Now, given a set of
these meetings, how would I order them so that they would go Sunday,
Monday, Tuesday, Wednesday, Thursday, Friday. note these meetings don't
have dates, just day of week and time. Oh, and they're coming from a
MySQL database.
Dec 20 '05 #1
3 1194
John Meyer wrote:
MySQL database.


Please bring a little bit of life to comp.databases.mysql

--
E. Dronkert
Dec 20 '05 #2
John Meyer wrote:
Okay, I have a database listing various meetings. The meetings have a
day of the week and a time (Say Sunday at 8:00). Now, given a set of
these meetings, how would I order them so that they would go Sunday,
Monday, Tuesday, Wednesday, Thursday, Friday. note these meetings don't
have dates, just day of week and time. Oh, and they're coming from a
MySQL database.

create table daysofweek (weekdaynumber int, weekdayname varchar(9));
insert daysofweek values (0, 'Monday');
insert daysofweek values (1, 'Tuesday');
insert daysofweek values (2, 'Wednesday');
insert daysofweek values (3, 'Thursday');
insert daysofweek values (4, 'Friday');
insert daysofweek values (5, 'Saturday');
insert daysofweek values (6, 'Sunday');

Now link your tables together with daysofweek and ORDER BY
weekdaynumber.

If you want the week to start on Wednesdays
select ... order by ((weekdaynumber + 5) % 7)

Dec 20 '05 #3
Mara Guida wrote:
John Meyer wrote:
Okay, I have a database listing various meetings. The meetings have a
day of the week and a time (Say Sunday at 8:00). Now, given a set of
these meetings, how would I order them so that they would go Sunday,
Monday, Tuesday, Wednesday, Thursday, Friday. note these meetings don't
have dates, just day of week and time. Oh, and they're coming from a
MySQL database.


create table daysofweek (weekdaynumber int, weekdayname varchar(9));
insert daysofweek values (0, 'Monday');
insert daysofweek values (1, 'Tuesday');
insert daysofweek values (2, 'Wednesday');
insert daysofweek values (3, 'Thursday');
insert daysofweek values (4, 'Friday');
insert daysofweek values (5, 'Saturday');
insert daysofweek values (6, 'Sunday');

Now link your tables together with daysofweek and ORDER BY
weekdaynumber.


Thanks for pointing out an obvious and simple solution.
Dec 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Joel Burton | last post by:
The newly-formed Zope/Python Users Group of DC announces our upcoming meeting schedule: Mo Jul 19: Zope -- presentation on Archetypes by Joel Burton Th Aug 5: Python -- no topic yet Mo Aug...
0
by: Jeff Rush | last post by:
The Dallas-Ft. Worth Pythoneers are having three meetings this week. Thursday, November 10th (i.e. Every Second Thursday) From 7 pm until 10 pm at Snuffer's Restaurant and Bar in Addison on...
11
by: samuelberthelot | last post by:
Hi, I've got 3 input HTML (dropdown lists) on my page. One for selecting a Month, one for the day, one for the year. Very simple... My problem is that I'd like to update the Days one according...
2
by: ft310 | last post by:
Te whole point is to provide the User a disclaimer and it they except to continue on with the original (?) format. The 'calling' web page generates something like "http://rhodeisland-...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.