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 2 of 2

Thread: DateDiff

  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DateDiff

    Hi there...I am trying to see if a Followup date matches exactly with the time now....dont know if both are in the same format and wonder if something like this might work? The Followup date from the database shows: 5/7/2007 1:14:00 PM


    <% if datediff("s",Now, AllRecords("FollowupDate"))=60 then
    else
    end if

    Thanks!

  • #2
    Senior Coder TheShaner's Avatar
    Join Date
    Sep 2005
    Location
    Orlando, FL
    Posts
    1,126
    Thanks
    2
    Thanked 40 Times in 40 Posts
    I would do something like:
    Code:
    Dim fol_date
    fol_date = CDate(AllRecords("FollowupDate"))
    If (DateDiff("d", Date, fol_date) = 0) Then
      'Code for same dates
    Else
      'Code for different dates
    End If
    When grabbing from a DB, I always find it best practice to do a conversion on the value to make sure it's in the right format, which is why I use CDate() on the FollowupDate value. I then do a DateDiff on the "day" value to see if they differ in days at all. If they don't, the difference will be zero, and so you can execute the code that performs when the two dates are the same.

    -Shane


  •  

    Posting Permissions

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