|
| |
|
|
achappell
Posts: 12 Joined: 8/16/2005 Status: offline
|
SQL Select Statement - Day of Week - 2/6/2007 11:37:56
I am trying to find a way to select a record based on the current day of the week. I have a table with 7 records in it, one for each day of the week. It looks similar to this: ID Day_Week Message 1 Monday The special for Monday is... 2 Tuesday The special for Tuesday is... 3 Wednesday The special for Wednesday is... 4 Thursday The special for Thursday is... 5 Friday The special for Friday is... 6 Saturday The special for Friday is... 7 Sunday The special for Sunday is... How would I build my Select statement to, for example, select the Monday record if the current day was Monday?
|
|
|
|
ou812
Posts: 1741 Joined: 1/5/2002 From: San Diego Status: offline
|
RE: SQL Select Statement - Day of Week - 2/6/2007 11:51:06
If you're using ASP you can use the weekday(date()) to obtain the numbered day of week, then you can select which one. Something like: dayofweek = weekday(date()) select Message from table where ID = dayofweek
_____________________________
-brian Black Holes suck. EnterpriseDB: Enterprise-class relational database management system PostgreSQL: The world's most advanced open source database
|
|
|
|
achappell
Posts: 12 Joined: 8/16/2005 Status: offline
|
RE: SQL Select Statement - Day of Week - 2/6/2007 18:11:04
Thanks that worked great! quote:
weekday(date())
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|