|
-
Jul 21st, 2001, 11:48 AM
#1
Thread Starter
Hyperactive Member
Date
How can I understand 5 days past date.
Like: today-5=five days past date from today.
Thanks for help.
-
Jul 21st, 2001, 11:51 AM
#2
Hyperactive Member
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
-
Jul 21st, 2001, 12:13 PM
#3
Fanatic Member
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.
-
Jul 21st, 2001, 01:20 PM
#4
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|