Results 1 to 4 of 4

Thread: Date

  1. #1

    Thread Starter
    Hyperactive Member samsyl's Avatar
    Join Date
    Jun 2001
    Location
    London
    Posts
    338

    Date

    How can I understand 5 days past date.

    Like: today-5=five days past date from today.

    Thanks for help.

  2. #2
    Hyperactive Member beasty1711's Avatar
    Join Date
    Mar 2001
    Posts
    418
    You can use the datediff function

    something like datediff(date1,date2)
    "...They even have the internet on computers..." :- Homer Simpson

    "Second Place is First Looser" :- No Fear

  3. #3
    Fanatic Member HaxSoft's Avatar
    Join Date
    May 2000
    Location
    Ohio
    Posts
    593
    You can also use the DateAdd function... The function has the following syntax:

    DateAdd(Interval, Number, Date)

    For example, if you want a date that lies 5 days earlier than today, then use this code:

    Code:
      Dim FiveDaysAgo As Date
    
      FiveDaysAgo = DateAdd("d", -5, Now())  ' get today and subtract 5 days
    
      Debug.Print "Today is " & Now()
      Debug.Print "5 days ago was " & FiveDaysAgo
    The Interval argument can be "s" for seconds, "n" for minutes, "h" for hours, "d" for days, "w" for weeks, "m" for months, "y" for years, and there are others....

    Anyway, the Number argument can be negative, zero, or positive. Specifying a negative number subtracts time indicated by number and interval, e.g. -5 and "n" to subtract five minutes. Specifying a positive number will add the time specified by the interval and number.

    The Date argument is simply the date to add/subtract to/from.

    Hope this helps.

  4. #4

    Thread Starter
    Hyperactive Member samsyl's Avatar
    Join Date
    Jun 2001
    Location
    London
    Posts
    338

    thanks

    Thanks. It is working.

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