Native functions in VBScript: Date and time

December 2016





FunctionDescription
DateReturns the system date
DateAdd(interval, number, date)Adds a time interval (interval) to a date (date). The interval is a string that can have the following values:
  • "yyyy" Year
  • "q" Quarter
  • "m" Month
  • "y" Day of the year
  • "d" Day
  • "w" Number of the week
  • "ww" Week of the year
  • "h" Time
  • "n" Minute
  • "s" Second

The number specifies the numbner corresponding to the interval. If number is negative, it will be a subtraction..
DateDiff(interval, date1, date2 [,firstdayofweek[, firstweekofyear]])Returns the number of intervals between two dates. interval is a string representing the type of interval used to calculate the difference between

date1 and date2. interval can have the following values:
  • "yyyy" Year
  • "q" Quarter
  • "m" Month
  • "y" Day of the year
  • "d" Day
  • "w" Number of the week
  • "ww" Week of the year
  • "h" Time
  • "n" Minute
  • "s" Second
DatePart(interval, date[, firstdayofweek[, firstweekofyear]])Returns a specific part of a given date. interval is a string representing the type of interval used for the data returned by the DatePart function. interval can have the following values:
  • "yyyy" Year
  • "q" Quarter
  • "m" Month
  • "y" Day of the year
  • "d" Day
  • "w" Number of the week
  • "ww" Week of the year
  • "h" Time
  • "n" Minute
  • "s" Second

  • firstdayofweek is an optional argument to specify which day will be considered as the first day of the week:
    • vbUseSystemDayOfWeek (0) uses the default values ??of API NLS (National Language Support).
    • vbSunday (1) Sunday (default
    • vbMonday (2) Monday
    • vbTuesday (3) Tuesday
    • vbWednesday (4) Wednesday
    • vbThursday (5) Thursday
    • vbFriday (6) Friday
    • vbSaturday (7) Saturday

    firstweekofyear is an optional argument to specify which week will be considered as the first week of the year:
    • vbUseSystemDayOfWeek (0) uses the default values ??of API NLS (National Language Support).
    • vbFirstJan1 (1) selects the week including January 1st (default)..
    • vbFirstFourDays (2) selects the week containing at least four days in the new year.
    • vbFirstFullWeek (3) uses the first full week of the year..
    DateSerial(year, month, day)Returns a variant of the Date subtype, obtained from the number of the year, month and day.
    DateValue(date)Returns a variant of the Date subtype obtained from the Date string passed as argument. The expected format for the date is specified in the Regional and Language Settings section of the Control Panel.
    Day(date)Returns the day of the month for the specified date argument.
    Hour(time)Returns an integer between 0 and 23, representing the number of hours, corresponding to the time passed as argument.
    Minute(time)Returns an integer between 0 and 59, representing the number of minutes corresponding to the number of hours passed as argument..
    Month(date)Returns the month number between 1 and 12, corresponding to the date passed as argument.
    MonthName(date)Returns the name of the month corresponding to the date passed as argument.
    NowReturns the system date and time.
    Second(time)Returns an integer between 0 and 59, representing the number of seconds for the time passed as argument.
    TimeReturns a variant of the Date subtype representing the system time.
    TimerReturns the number of seconds elapsed since midnight.
    TimeSerialTime obtained from the hours, minutes and seconds
    TimeValueConverting a string in Time format
    WeekdayDays of the week
    WeekDayNameName of specific week day
    YearYear number





    Original document published CommentcaMarche.net.

    Related :

    This document entitled « Native functions in VBScript: Date and time » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.