Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 12th, 2003, 02:08 PM
Authorized User
Join Date: Jun 2003
Location: Gulfport, Ms, USA.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default Results based on Date

I know this has been covered a million times already, and there's already on topic here that covers this but I can't find it.

I want to query a database. After I get my data, I would like to display based on day of the week.

Something along the lines of :

If dtNow = Now() Then
strWhatever = "red"

My apologies, but I'm not sure exactly how to explain what I'm looking for. If anyone could help, or point me to the original topic, I'll gladly hand over one of my co-workers... :D

Reply With Quote
  #2 (permalink)  
Old August 12th, 2003, 02:28 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

Hi there,

You'll need to take a look at the Weekday method which you can find in the Windows Script section of the MSDN:

The Weekday method returns a 1 based number for the current day of the week, starting at 1 for a Sunday by default.

So, this should work:

If Weekday(dtNow) = Weekday(Now()) Then
  str.... etc
End If

Or, when you need multiple days, use a Select Case statement:

Select Case Weekday(dtNow)
  Case 1 ' Sunday
  Case 2 ' Monday
  etc etc
End Select
or define constants for the weekdays if you need them more often, to improve the readability of the code:

Dim vbSunday
Dim vbMonday
vbSunday = 1
vbMonday = 2
Select Case Weekday(dtNow)
  Case vbSunday
  Case vbMonday
  etc etc
End Select
Hope this helps,


Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter GridView Results by date range srinredd59 ASP.NET 2.0 Basics 0 December 27th, 2006 03:53 PM
Calculating and filtering age based on date shawnm Classic ASP Databases 4 November 12th, 2005 06:08 AM
how to show 2 different values based on date maria Crystal Reports 1 August 4th, 2004 08:21 AM
Date based query when date is nvarchar MichaelTJ SQL Language 4 January 12th, 2004 09:57 PM
Query based on date calculation? skinny Access 5 September 30th, 2003 03:20 PM

All times are GMT -4. The time now is 06:38 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.