Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jan 2005
    Location
    London, UK
    Posts
    47
    Thanks
    2
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    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

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts

  • #4
    New Coder
    Join Date
    Jan 2005
    Location
    London, UK
    Posts
    47
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks for the fast response guys!

    I will try them out tonight and let you know how I got on.

  • #5
    New Coder
    Join Date
    Jan 2005
    Location
    London, UK
    Posts
    47
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    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) %>

  • #7
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    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

  • #8
    Regular Coder
    Join Date
    Aug 2002
    Location
    Texas
    Posts
    287
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •