Click to See Complete Forum and Search --> : Calculating Dates
equuelus
Mar 14th, 2001, 07:21 PM
Greetings..
How could I get the scale of the number of days, hours, minutes, seconds from two different general date format... ie.
11/11/11 11:11 AM and 12/12/12 12:12 AM
will give an output of
1 month
1 day
1 hour
1 minutes
get what i mean??
now how do i write the code..
thanks in advance to those who reply
Active
Mar 14th, 2001, 11:13 PM
11/11/11 11:11 AM and 12/12/12 12:12 AM
will give an output of
1 month
1 day
1 hour
1 minutes
Do you want the difference between the month parts
Difference between the dateparts and the Difference
Between yearparts.. ....(That will be like what you have written above ...but seems useless..) :)
or
You want the exact Number of days,months,Years etc.. between two given dates in different format ?
equuelus
Mar 14th, 2001, 11:26 PM
yea.. i want the exact no. of hours, days, month, years..ect..between two given dates..
thanks for your reply guru.
Use the DateDiff function.
Here is the syntax for the DateDiff function.
Syntax
DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])
The DateDiff function syntax has these named arguments:
Part - Description
interval - Required. String expression that is the interval of time you use to calculate the difference between date1 and date2.
date1, date2 - Required; Variant (Date). Two dates you want to use in the calculation.
firstdayofweek - Optional. A constant that specifies the first day of the week. If not specified, Sunday is assumed.
firstweekofyear - Optional. A constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs.
Settings
The interval argument has these settings:
Setting - Description
yyyy - Year
q - Quarter
m - Month
y - Day of year
d - Day
w - Weekday
ww - Week
h - Hour
n - Minute
s - Second
Usage
?DateDiff("m", "11/11/11", "12/12/12")
equuelus
Mar 15th, 2001, 05:45 AM
thanks matthew
that was really helpful..emm.. wondering where could i find good reference on built in vb functions plus the syntax..
If you are using VB, and have it installed along with a help file (or MSDN Libary), everything is listed in there.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.