Results 1 to 2 of 2

Thread: working with date please help

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Location
    london
    Posts
    31
    i am trying to write code that will tell me if one date is before another. This is the code i have writen but it will not work please help me.

    if date1 > date2 then

    if any of ou can please help
    thanks
    dave
    D Stonebanks

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658

    Cool DateDiff

    You can use DateDiff. In this example it returns the number of days different. If it is a negative number then the second date is smaller than the first. If it is a positive number then the second date is greater than the first.

    Code:
      myNum = DateDiff("d", date1, date2)
      
      If myNum < 0 Then
        'date2 is smaller than date1
      ElseIf myNum > 0 Then
        'date2 is greater than date1
      Else
        'the dates are the same
      End If
    Iain, thats with an i by the way!

Posting Permissions

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



Click Here to Expand Forum to Full Width