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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    # days left from date

    hi, i need a bit of code that will count down from 90 days from a
    <%=objRS("Date")%> section in a database.

    any ideas?
    Web and Business Development from Cornwall - Startbar.co.uk

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    This?
    Code:
    dim d, d2
    d = objRS("Date")
    if not isnull(d) and isdate(d) then
      d2 = dateadd("D", 90, d)
      response.write d2
    else
      response.write "Null or invalid date"
    end if

  • #3
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts
    quite possibly. I need to show the date on the page as well as the '# days left' so whats the code for the if i wanted to say:

    for example.

    'you have 84 days left'

    thanks
    Web and Business Development from Cornwall - Startbar.co.uk

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    How about this?
    Code:
    dim d, d2, daysLeft
    d = objRS("Date")
    if not isnull(d) and isdate(d) then
      d2 = dateadd("D", 90, d)
      daysLeft = datediff("D", Date(), d2)
      response.write "You have " & daysLeft & " days left."
    else
      response.write "Null or invalid date"
    end if

  • #5
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts
    let me try it..
    Web and Business Development from Cornwall - Startbar.co.uk

  • #6
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so it counts from the 'Date' Value?

    so if the date that the entry was added was '01/01/01' and the date of viewing was '02/01/01' it would show 89 days left?

    thats great, thanks
    Web and Business Development from Cornwall - Startbar.co.uk


  •  

    Posting Permissions

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