Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-11-2005, 03:55 PM   PM User | #1
Carl_FK
New Coder

 
Join Date: Jan 2005
Location: London, UK
Posts: 47
Thanks: 2
Thanked 0 Times in 0 Posts
Carl_FK is an unknown quantity at this point
Question Help with Comparing Dates

Hi Everyone,

This is my first post, so wohey!

Anyway, to the point, I would like some help on comparing dates.
Basically, I have a date (dd/mm/yy) in my SQL database, which I can connect to, and output onto a page. I need to compare the date in my database, with todays date.
And, if todays date is after (or equal to) the date in the database, it outputs a string of text.

Sounds quite simple... although I'm not sure how to do this.
P.S. I'm quite experienced with ASP although never tried this.

Thanks,

Carl.
Carl_FK is offline   Reply With Quote
Old 01-12-2005, 04:12 AM   PM User | #2
Bullschmidt
Regular Coder

 
Join Date: Aug 2002
Location: USA
Posts: 478
Thanks: 0
Thanked 2 Times in 2 Posts
Bullschmidt is an unknown quantity at this point
Hi Carl!

If objRS("TheDateField") <= Date() Then
...
End If
__________________
J. Paul Schmidt
www.Bullschmidt.com - Freelance Web and Database Developer
www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips
Bullschmidt is offline   Reply With Quote
Old 01-12-2005, 04:22 AM   PM User | #3
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
DateDiff
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 01-12-2005, 12:16 PM   PM User | #4
Carl_FK
New Coder

 
Join Date: Jan 2005
Location: London, UK
Posts: 47
Thanks: 2
Thanked 0 Times in 0 Posts
Carl_FK is an unknown quantity at this point
Thanks for the fast response guys!

I will try them out tonight and let you know how I got on.
Carl_FK is offline   Reply With Quote
Old 01-20-2005, 01:23 PM   PM User | #5
Carl_FK
New Coder

 
Join Date: Jan 2005
Location: London, UK
Posts: 47
Thanks: 2
Thanked 0 Times in 0 Posts
Carl_FK is an unknown quantity at this point
Hi Guys

Bullschmidt, unfortunately yours didnt seem to do anything... There were no errors, but it didnt return a string

glenngv, i had a look at yours, but it doesnt seem like what I want (correct me if i'm wrong), but do you recon you could give an example.

Any other ideas?

Thanks guys
Carl_FK is offline   Reply With Quote
Old 01-20-2005, 02:19 PM   PM User | #6
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
Quote:
Originally Posted by Carl_FK

glenngv, i had a look at yours, but it doesnt seem like what I want (correct me if i'm wrong), but do you recon you could give an example.
The link that I posted already gives you examples.

<%=DateDiff("d", Date, "1/1/2000") %>

<% olddate = #6/26/43# %>
<% nowdate = Now %>
<% =DateDiff("S", nowdate, olddate) %>
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 01-20-2005, 06:15 PM   PM User | #7
Bullschmidt
Regular Coder

 
Join Date: Aug 2002
Location: USA
Posts: 478
Thanks: 0
Thanked 2 Times in 2 Posts
Bullschmidt is an unknown quantity at this point
Quote:
Originally Posted by Carl_FK
Hi Guys

Bullschmidt, unfortunately yours didnt seem to do anything... There were no errors, but it didnt return a string
Well the only other thing I can think of is to make sure that the field in question in the database table really is a date/time field.
__________________
J. Paul Schmidt
www.Bullschmidt.com - Freelance Web and Database Developer
www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips
Bullschmidt is offline   Reply With Quote
Old 01-20-2005, 09:31 PM   PM User | #8
fractalvibes
Regular Coder

 
Join Date: Aug 2002
Location: Texas
Posts: 287
Thanks: 0
Thanked 0 Times in 0 Posts
fractalvibes is an unknown quantity at this point
In SQL:

select col1
,col2
etc.
(CASE WHEN DateField <= CURRENT DATE THEN
'Yep'
Else
'Nope'
End) AS DoPrint
from your table
where .....

in code:
If rs("DoPrint") = "yep" then
'go ahead and output your string of text
End if
fractalvibes is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 05:13 AM.


Advertisement
Log in to turn off these ads.