Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - sending data to asp page based on date
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

sending data to asp page based on date

 Post Reply Post Reply
Author
DevDevil View Drop Down
Newbie
Newbie


Joined: 27 July 2004
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote DevDevil Quote  Post ReplyReply Direct Link To This Post Topic: sending data to asp page based on date
    Posted: 27 July 2004 at 3:01pm
I have a table in SQL Server that has 3 rows, LineID, Information, and Expires. It's for a Church calendar and they want to input the data in bulk for different dates. The Expires is the last date they want to info to show. If today's date is 07/27/2004 and there is a record like LineID - 7, Information - Field Trip, and Expires - 07/26/2004, than it should not be seen today. But, if there is a record like LineID - 8, Information - Teacher Inservice, and Expires - 07/28/2004, then it should be seen as long as 07/28/2004 is <= today's date. Basically as soon as the Expires value is greater than today's date the Information can't be viewed, but the Information with the highest Expires value that is less than today's date is the one that is seen by the users. I've written several scripts that "in my mind" should work... but...
Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post Posted: 28 July 2004 at 7:58am
so, what do you actually want help with?
Back to Top
DevDevil View Drop Down
Newbie
Newbie


Joined: 27 July 2004
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote DevDevil Quote  Post ReplyReply Direct Link To This Post Posted: 28 July 2004 at 10:37am

well, i guess i need help with either someone telling me what's wrong with my script or showing me a better way. here's mine...
Set rstMercy = Server.CreateObject("ADODB.Recordset")
strSQL1 = "SELECT Max(LineID) " _
& "AS MaxID From DatedMaterial WHERE " _
& "ViewUntil <= '" & CurrentDateTime & "'"
rstMercy.Open strSQL1, connStr
Set rstMercy2 = Server.CreateObject("ADODB.Recordset")
strSQL2 = "SELECT * FROM DatedMaterial WHERE " _
& "LineID = '" & rstMercy("MaxID") & "'"
rstMercy2.Open strSQL2, connStr

Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 28 July 2004 at 11:27am

I'd suggest working out the <= date selection statement before addining the additional criteria perhaps with something like the following...

strSQL1 = "SELECT * FROM DatedMaterial " & _
"WHERE datediff(day, ViewUntil, GETDATE()) <= 0"

The most common error using dates in MSSQL queries is invalid format on input dates The second common error is storing the dates in an invalid format to begin with. - e.g. MMDDYYYY is not a vaild date, MM-DD-YYYY is a valid date. You may want to run a query against the db to print some of the dates and make sure they're what you expect. If this proves to be the problem, check out the IsDate and CDate asp commands.

EDIT: A lot of people don't use date fields at all, they store dates as small text fields formatted as YYYYMMDD or YYYY-MM-DD.



Edited by dpyers

Lead me not into temptation... I know the short cut, follow me.
Back to Top
DevDevil View Drop Down
Newbie
Newbie


Joined: 27 July 2004
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote DevDevil Quote  Post ReplyReply Direct Link To This Post Posted: 28 July 2004 at 12:32pm
I really appreciate the info. After tweaking your suggestion a bit everything works great now. These forums are a great resource.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.