Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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

  #2 (permalink)  
Old August 12th, 2003, 02:28 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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.

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

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