Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 05-20-2006, 03:18 AM   #1
Solid State Member
 
Join Date: Jan 2006
Posts: 8
Exclamation Help needed with asp date()

Question:
I must display a series of 'special offers', each of which have a date. However, i must only display those offers which have dates that are still valid (ie the offer is still running). I currently have the code which accesses the DB..

<% set conn = server.createobject("ADODB.connection")
conn.open "banking", "Aut2006", "assign2"
sql = "SELECT * from specialOffer"
set rs = conn.execute(sql) %>

and in the xhtml body have..

<%

If CDate(RS("fromDate")) <= CDate(Now) and CDate(RS("toDate")) >= CDate(Now)
Then
response.write ("<p class="specials"> = rs('ShortDesc')</p>")

end if

%>

But not working, could anyone help with this? Thanks

-Trez
__________________

Trez is offline   Reply With Quote
Old 05-20-2006, 09:38 AM   #2
j03
~~~~~~~~
 
Join Date: Jan 2005
Location: Wales
Posts: 5,556
Send a message via MSN to j03
Default Re: Help needed with asp date()

thats like what i am trying to do - but with ASP
__________________

j03 is offline   Reply With Quote
Old 05-20-2006, 02:40 PM   #3
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 7,999
Default Re: Help needed with asp date()

OK the trouble is that once you've gotten the data from the database it's just a string.

therefor.
01/06/2006 is less than
02/06/2005 because the most significant digit in the second data (2) is greater than the most significant digit from the first date (1).

you need to edit the sql statement to do the selecting for you.

sql = "select * from specaloffer where fromdate <= Cdate(now) AND todate >= cDate(now)"

(that will only select offeres where the dates are valid (assuming that the fields are set as date fields and not text fields in the databse).
__________________
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 05-21-2006, 08:14 AM   #4
Solid State Member
 
Join Date: Jan 2006
Posts: 8
Default Re: Help needed with asp date()

Ok thanks root much appreciated
Trez is offline   Reply With Quote
Reply

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 02:20 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0