If today is January 2011, I would like to know from March 2010, calculate this is a few months the best answer
<%=datediff ("M", "2010-03-01", "2011-01-01")%> other answers total 2
DateDiff ("M", "2010-03-01", "2011-01-01")
DateDiff function
Function: Returns the time interval between two dates.
Syntax: DateDiff (interval, date1, date2 [, firstdayofweek][, FirstWeekOfYear]])
Syntax parameters:
Interval must be selected. A string expression that is used to calculate the time interval between Date1 and Date2. For numeric values, see the "Settings" section.
Date1, Date2 must choose. An expression of a date. Two dates used for the calculation.
FirstDayOfWeek Optional. Specifies the constant for the first day of the week. If not specified, the default is Sunday. For numeric values, see the "Settings" section.
FirstWeekOfYear Optional. Specifies a constant for the first week of the year. If not specified, the default is the week of January 1. For numeric values, see the "Settings" section
Parameter settings:
The interval parameter can have the following values:
Set description
YYYY years
Q Quarter
M month
Y number of days in a year
D-Day
W Number of days in a week
WW Week
H hours
M minutes
s seconds
<%
Response.Write DateAdd ("M", 1,date ())
%>
Do not understand the words refer to the following:
Date ()
Function Description: Returns the current system date.
Syntax format: Date ()
Parameter description: None
code example: Date ()
return Result: 2004-09-14
DATEADD ()
Function Description: Returns a date that has been changed.
Syntax format: DATEADD (timeinterval,number,date)
Parameter description: TimeInterval is to increase the type of time interval, such as "Y", "M", "D", "H" and so on; Number is the amount of time interval to increase; Date is the base time for the increase in time.
code example: Dataadd ("M", 1,cdate ("2004-09-14 17:12:23")
Returned results: 2004-10-14 17:12:23
Here's a tip (for starters), if number is negative, it is equivalent to subtracting ABS (number) intervals.
DateDiff ()
Function Description: Returns the difference between two dates.
Syntax format: DateDiff (Timeinterval,date1,date2 [, FirstDayOfWeek [, firstweekofyear>>)
Parameter Description: TimeInterval represents the type of time between intervals, such as "M" for "month".
code example: DateDiff ("D", "2000-1-1", "1999-8-4")
Return result: From 1999-8-4 to 2000 there are 150 days.