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: 1612 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
EnterpriseDB: Enterprise-class relational database management system PostgreSQL: The world's most advanced open source database