Features
      Ask DevGuru
      ASP Resources
      Find the Bug
      Knowledge Base
      Links
      Tips of the Week
      Tutorials
  Products
      dgCalendar
      dgCharge New!
      dgChart New!
      dgFileUpload
      dgReport New!
      dgSort
      dgTree
  Site
      Authoring
      Coming Soon
      DevGuru Resume
      Link to Us
      Merchandise
      Sponsorships
      Testimonials
      What's New
  Technologies
      ADO 2.6
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      Transact-SQL Syntax
      VBScript
      WML
      WMLScript
      WSH
      XML DOM

              











FUNCTION:  DateDiff( )

Implemented in version 2.0
 
DateDiff(Interval, Date1, Date2, FirstDayofWeek, FirstWeekofYear)
 
The DateDiff function calculates the amount of time between two different dates.
 
There are three mandatory arguments.
 
Interval
 
The Interval argument defines the the type of time interval you wish to use to calculate the time difference.
 
Only the following settings can be used. You must place the setting inside a pair of double quotes.
 
SETTING DESCRIPTION
YYYY Year
Q Quarter
M Month
Y Day Of Year
D Day
W WeekDay
WW Week Of Year
H Hour
N Minute
S Second

 
Date1
 
The Date1 argument is the first date.
 
Date2
 
The Date2 argument is the second date.
 
Code:
<%=DateDiff("d", Date, "1/1/2000") %>
 
Output:
291
 
The order of the two dates determines if the difference is represented as a positive or negative value.
 
Code:
<% olddate = #6/26/43# %>
<% nowdate = Now %>
<% =DateDiff("s", nowdate, olddate) %>

 
Output:
-3130748108
 
There are two optional arguments.
 
FirstDayofWeek
 
The FirstDayofWeek argument must only use the constants or values defined below in the Date And Time CONSTANTS.
 
CONSTANT VALUE DESCRIPTION
VBSunday 1 Sunday
VBMonday 2 Monday
VBTuesday 3 Tuesday
VBWednesday 4 Wednesday
VBThursday 5 Thursday
VBFriday 6 Friday
VBSaturday 7 Saturday
VBFirstJan1 1 Week of January 1
VBFirstFourDays 2 First week of the year that has at least four days
VBFirstFullWeek 3 First full week of the year
VBUseSystem 0 Use the date format of the computer's regionsl settings
VBUseSystemDayOfWeek 0 Use the first full day of the week as defined by the system settings

 
In this example, Tuesday is defined to be the first day of the week. The output is how many weeks, which are now defined to start on Tuesday, are left between the current date and 1/1/2001.
 
Code:
<% =DateDiff("w", Date, "1/1/2001", 3) %>
 
Output:
93
 
Code:
<% =DateDiff("w", Date, "1/1/2001", VBTUESDAY) %>
 
Output:
93
 
FirstWeekofYear
 
The FirstWeekofYear argument must only use the constants or values defined in the Date And Time CONSTANTS which are listed above.
 
Code:
<% =DateDiff("ww", Date, "1/1/2001", 1, VBFIRSTFOURDAYS)%>
 
Output:
94


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information