Date & Time

Methods

(inner) accessed()

Indicates the time and date when the document was last accessed by a Notes® client, whether for reading or editing.

Throws:

No plans to implement

Type
Error

(inner) adjust(dateOrDateList, years, months, days, hours, minutes, seconds) → {TextOrTextList}

Adjusts the specified Date value by the number of years, months, days, hours, minutes, and/or seconds you specify. The amount of adjustment may be positive or negative.

Parameters:
NameTypeDescription
dateOrDateListDateOrDateList

The Date or list of Dates you want to increment. This should be a single date, not a range.

yearsnumber

The number of years to increment by.

monthsnumber

The number of months to increment by.

daysnumber

The number of days to increment by.

hoursnumber

The number of hours to increment by.

minutesnumber

The number of minutes to increment by.

secondsnumber

The number of seconds to increment by.

See
Returns:

The adjusted date string or list of adjusted date strings.

Type: 
TextOrTextList
Example
rosettajs.DateTime.adjust(rosettajs.DateTime.date('6/30/95'), 2, 2, 2, 0, 0, 0); // returns '7/30/1995'

(inner) businessDays(startDate, endDate, daysToExcludeopt, datesToExcludeopt) → {NumberOrNumberList}

Returns the number of business days in one or more date ranges. Inclusive of the date ranges, and excluding provided optional weekends and holidays.

Parameters:
NameTypeAttributesDescription
startDateDateOrDateList

Date as string or Date type, or list of Dates. The start of each date range.

endDateDateOrDateList

Date as string or Date type, or list of Dates. The end of each date range.

daysToExcludeNumberOrNumberList<optional>

Numer or number list. Optional. Days of the week not counted as business days, where 1 is Sunday and 7 is Saturday. Decimal numbers are rounded to integers. Numbers other than 1-7 are ignored. (AKA Weekends)

datesToExcludestring | Array.<string> | Date | Array.<Date><optional>

Date as string or Date type, or list of Dates. Optional. Dates not counted as business days. (AKA Holidays)

See
Returns:

The number of days from startDates to endDates, inclusive, less daysToExclude and datesToExclude that fall within the date range.

Type: 
NumberOrNumberList
Example
rosettajs.DateTime.businessDays("01/01/2001", "12/31/2001", [1, 7], HOLIDAYS); // returns 251, where HOLIDAYS include a list of 10 major US holidays in 2001

(inner) created() → {Date}

Returns the Date when the document was created.

See
Returns:

Date. The date when the current document was created.

Type: 
Date
Example
rosettajs.DateTime.created(); // returns Wed Aug 04 2021 12:23:17 GMT-0400 (Eastern Daylight Time) for the "Hot Chocolate" recipe document

(inner) date(yearOrDateTime, monthopt, dayopt, houropt, minuteopt, secondopt) → {string}

Constructs the date from year, month, and day of month or translates numbers for the various components of time and date, then returns the Date value.

Parameters:
NameTypeAttributesDescription
yearOrDateTimeDateOrDateList

The year that you want to appear in the resulting date. You must specify an entire four-digit year. (For example, use 1996, not 96). Or Time-date or Date list. For a Date value such as @Now or [10/31/93 12:00:00], @Date removes the time portion of the value, leaving only the date.

monthnumber<optional>

Optional (when DateTime provided). The month that you want to appear in the resulting date. (For example, use 1 to specify January).

daynumber<optional>

Optional (when DateTime provided). The day that you want to appear in the resulting date.

hournumber<optional>

Optional. The number of hours. This value will be truncated from the resulting date.

minutenumber<optional>

Optional. The number of minutes. This value will be truncated from the resulting date.

secondnumber<optional>

Optional. The number of seconds. This value will be truncated from the resulting date.

See
Returns:

A string representation of the date and time of the given year, month and day  and  www.oasis-open.org

Type: 
string
Example
rosettajs.DateTime.date(12, 12, 12); // returns Thu Dec 12 1912 00:00:00 GMT-0500 (Eastern Standard Time)

(inner) dateDif(start_date, end_date, unit) → {Number}

Calculates the number of days, months, or years between two dates.

Parameters:
NameTypeDescription
start_dateCustomDateType

A date that represents the first, or starting date of a given period.

end_dateCustomDateType

A date that represents the last, or ending, date of the period.

unitstring

The type of information that you want returned, where:

  • "Y": The number of complete years in the period.
  • "M": The number of complete months in the period.
  • "D": The number of days in the period.
  • "MD": The difference between the days in start_date and end_date. The months and years of the dates are ignored.
  • "YM": The difference between the months in start_date and end_date. The days and years of the dates are ignored
  • "YD": The difference between the days of start_date and end_date. The years of the dates are ignored.
See
Returns:

Days, months, or years between given dates.

Type: 
Number
Examples
rosettajs.DateTime.dateDif("1/1/2001", "1/1/2003", "Y"); // returns 2
rosettajs.DateTime.dateDif("6/1/2001", "8/15/2002", "D"); // returns 440

(inner) dateValue(date_text) → {Date}

Returns the string representation of the date and time from given text.

Parameters:
NameTypeDescription
date_textstring

Text that represents a date in an OpenFormula date format, or a reference to a value that contains text that represents a date in an OpenFormula date format.

See
Returns:

A string representation of the date and time of the given date.

Type: 
Date
Example
rosettajs.DateTime.dateValue("1/1/1900"); // returns Mon Jan 01 1900 00:00:00 GMT-0500 (Eastern Standard Time)

(inner) day(dateOrDateList) → {NumberOrNumberList}

Extracts the day of the month from the specified date.

Parameters:
NameTypeDescription
dateOrDateListDateOrDateList

The date, as a string, number, Date object, or Array of Date objects, containing the day value that you want to extract.

See
Returns:

Number or Number list. The number corresponding to the day of the month indicated by dateOrDateList. Returns -1 if the Date provided contains only a time value and not a date.  and  www.oasis-open.org

Type: 
NumberOrNumberList
Examples
rosettajs.DateTime.day(2958465); // returns 31 (open formula only)
rosettajs.DateTime.day(new Date(1900, 0, 1)); // returns 1

(inner) days(endDate, startDate) → {number}

Returns the number of days between two dates.

Parameters:
NameTypeDescription
endDateCustomDateType

A date that represents the last, or ending, date of the period

startDateCustomDateType

A date that represents the first, or starting date of a given period

See
Returns:

Number of days between two given dates.

Type: 
number
Example
rosettajs.DateTime.days("1/2/1900", "1/1/1900"); // returns 1

(inner) days360(endDate, startDate, methodopt) → {number}

Calculates the number of days between two dates based on a 360-day year.

Parameters:
NameTypeAttributesDescription
endDateCustomDateType

A date that represents the last, or ending, date of the period.

startDateCustomDateType

A date that represents the first, or starting date of a given period.

methodstring<optional>

Optional. A logical value that specifies whether to use the U.S. or European method in the calculation. The default is FALSE.

  • FALSE U.S. (NASD) method. If the starting date is the last day of a month, it becomes equal to the 30th day of the same month. If the ending date is the last day of a month and the starting date is earlier than the 30th day of a month, the ending date becomes equal to the 1st day of the next month; otherwise the ending date becomes equal to the 30th day of the same month.
  • TRUE European method. Starting dates and ending dates that occur on the 31st day of a month become equal to the 30th day of the same month.
See
Returns:

Number of days between two given dates based on a 360-day year.

Type: 
number
Example
rosettajs.DateTime.days360("1/1/1901", "12/31/1901", true); // returns 359

(inner) eDate(startDate, months) → {Date}

Returns the date and time that is the indicated number of months before or after the start date.

Parameters:
NameTypeDescription
startDateCustomDateType

A date that represents the first, or starting date of a given period.

monthsnumber

The number of months before or after start_date. A positive value for months yields a future date; a negative value yields a past date.

See
Returns:

The date of the given date and number of months.

Type: 
Date
Example
rosettajs.DateTime.eDate(rosettajs.DateTime.date(2011, 1, 23), 1); // returns Sun Feb 23 2011 00:00:00 GMT-0500 (Eastern Standard Time)

(inner) eoMonth(startDate, months) → {Date}

Returns the string representation of the date and time of the last day of the month before or after a specified number of months.

Parameters:
NameTypeDescription
startDateCustomDateType

A date that represents the first, or starting date of a given period.

monthsnumber

Number of months before or after start_date. A positive value for months yields a future date; a negative value yields a past date.

See
Returns:

The date of the given date number of months.

Type: 
Date
Example
rosettajs.DateTime.eoMonth("1/1/2005", 2); // returns Thu Mar 31 2005 00:00:00 GMT-0500 (Eastern Standard Time)

(inner) getCurrentTimeZone() → {string}

Returns the current operating system's time zone settings in canonical time zone format.

See
Returns:

Canonical time zone representing the time zone settings of the operating system. If the Notes time zone string is not found, the JavaScript time zone name is returned.

Type: 
string
Example
rosettajs.DateTime.getCurrentTimeZone(); // returns "Z=5$DO=1$DL=3 2 1 11 1 1$ZX=40$ZN=Eastern" if in the Eastern Time Zone

(inner) hour(dateOrDateList) → {NumberOrNumberList}

Extracts the number of the hour (0 through 23) from a specified Date.

Parameters:
NameTypeDescription
dateOrDateListDateOrDateList

The date, as a string, Date object, or Array of Date objects, with the hour that you want to extract.

See
Returns:

Number or Number list. Hour portion (or list of hours) of the given date.  and  www.oasis-open.org

Type: 
NumberOrNumberList
Examples
rosettajs.DateTime.hour("1/1/1900 1:00"); // returns 1
rosettajs.DateTime.hour(rosettajs.DateTime.date(95, 11, 20, 8, 58, 12)); // returns 8

(inner) interval(second) → {string}

Calculates the number of years, months, days, hours, minutes and seconds from a specified number of seconds.

Parameters:
NameTypeDescription
secondnumber

Number of seconds.

Returns:

A string representing the years, months, days, hours, minutes and seconds based on the given number of seconds.

Type: 
string
Example
rosettajs.DateTime.interval(10000000); // returns "P3M25DT17H46M40S"

(inner) isoWeekNum(date) → {number}

Returns the number of the ISO week number of the year for a given date.

Parameters:
NameTypeDescription
dateCustomDateType

The date.

See
Returns:

Number of the week in the year of given date.

Type: 
number
Example
rosettajs.DateTime.isoWeekNum("1/8/1901"); // returns 2

(inner) locale(action, localeTagopt) → {TextOrTextList}

Returns information about language codes.

Parameters:
NameTypeAttributesDescription
actionTextOrTextList

Text or text list with action keyword. One of the following: [NotesLocale] without locale-tag returns a text list containing all the content language codes. [NotesLocale] with locale-tag returns a text list or value containing each specified content language code, or a null string if the code is not recognized. A code is recognized if it is exact regardless of case. If the language is recognized but not the country or region, the language code alone is returned. [AltNameLocale] without locale-tag returns a text list containing all the alternate name language codes. [AltNameLocale] with locale-tag returns a text list or value containing each specified alternate user language code, or a null string if the code is not recognized. A code is recognized if it is exact regardless of case. The country or region is ignored where it is not part of the alternate user language code (most cases). [LanguageName] with locale-tag returns a text list or value spelling out the language for each specified language code, or a null string if the code is not recognized. [CountryName] with locale-tag returns a text list or value spelling out the country or region for each specified language code, or a null string if the code has no country or region, or it is not recognized. [LocaleName] with locale-tag returns a text list or value spelling out the language and country (or region), if applicable, for each specified language code, or a null string if the code is not recognized. The country or region is in parentheses and immediately (no space) follows the language. [LocaleName] : [NotesLocale] (concatenating these two keywords) returns a text list containing, for each content language code, the language name, the country or region name in parentheses, a vertical bar, and the language code. This list can be used in a keyword field where the locale name is the name and the language code is the alias. [LocaleName] : [AltNameLocale] (concatenating these two keywords) returns a text list containing, for each alternate name language code, the language name, the country or region name in parentheses, a vertical bar, and the language tag. This list can be used in a keyword field where the locale name is the name and the language code is the alias.

localeTagTextOrTextList<optional>

A language code or list of language codes. af,ar,ar-AE,ar-BH,ar-DZ,ar-EG,ar-JO,ar-KW,ar-LB,ar-MA,ar-OM,ar-QA,ar-SA,ar-TN,ar-YE,be,bg,ca,cs,cy, da,de,de-AT,de-CH,de-DE,de-LI,de-LU,el,en,en-AU,en-CA,en-GB,en-HK,en-IE,en-IN,en-JM,en-NZ,en-PH,en-SG, en-US,en-ZA,es,es-AR,es-BO,es-CL,es-CO,es-CR,es-DO,es-EC,es-ES,es-GT,es-HN,es-MX,es-NI,es-PA,es-PE, es-PR,es-PY,es-SV,es-US,es-UY,es-VE,et,fi,fr,fr-BE,fr-CA,fr-CH,fr-FR,fr-LU,gu,he,hi,hr,hu,id,is,it,it-CH, it-IT,ja,kk,ko,lt,lv,mk,mr,ms,ms-MY,mt,nl,nl-BE,nl-NL,no,no-NO,ny-NO,pl,pt,pt-BR,pt-PT,ro,ro-MD,ro-RO, ru,sk,sl,sq,sr,sv,ta,te,th,tr,uk,vi,x-KOK,zh-CN,zh-HK,zh-MO,zh-SG,zh-TW

See
Returns:

Returns the requested information about the language codes. Empty string if tag is not found.

Type: 
TextOrTextList
Examples
rosettajs.DateTime.locale([LanguageName]; "fr"); // returns "French"
rosettajs.DateTime.locale([LocaleName]; "fr-CA"); // returns "French(Canada)"

(inner) minute(dateOrDateList) → {NumberOrNumberList}

Extracts the number of the minutes from a specified Date.

Parameters:
NameTypeDescription
dateOrDateListDateOrDateList

The date, as a string, Date object, or Array of Date objects, of the minuntes you are trying to find.

See
Returns:

Number or Number list. Minutes portion (or list of minutes) of the given date.  and  www.oasis-open.org

Type: 
NumberOrNumberList
Examples
rosettajs.DateTime.minute("1/1/1900 1:30"); // returns 30
rosettajs.DateTime.minute(rosettajs.DateTime.date(95, 11, 20, 8, 58, 12)); // returns 58

(inner) modified() → {Date}

Returns the Date when the document was last modified.

See
Returns:

Date. The date when the current document was last modified.

Type: 
Date
Example
rosettajs.DateTime.modified(); // returns Mon May 22 2023 12:46:49 GMT-0400 (Eastern Daylight Time) for the "Hot Chocolate" recipe document

(inner) month(dateOrDateList) → {NumberOrNumberList}

Extracts the number of the month (1-12) from the specified date.

Parameters:
NameTypeDescription
dateOrDateListDateOrDateList

The date, as a string, Date object, or Array of Date objects of the month you are trying to find.

See
Returns:

Number or Number list. Month portion (or list of days) of the date (or list of dates).  and  www.oasis-open.org

Type: 
NumberOrNumberList
Examples
rosettajs.DateTime.month(2958465); // returns 12 (open formula only)
rosettajs.DateTime.month(new Date(1900, 0, 31)); // returns 1

(inner) netWorkDays(startDate, endDate, holidaysopt) → {number}

Returns the number of whole workdays between two dates. Working days excludes weekends and any dates identified in holidays.

Parameters:
NameTypeAttributesDescription
startDateDateType

A date that represents the first, or starting date of a given period.

endDateDateType

A date that represents the last, or ending, date of the period.

holidaysDateType | Array.<DateType><optional>

An optional range of one or more dates to exclude from the working calendar, such as state and federal holidays and floating holidays.

See
Returns:

The number of whole workdays between two dates.

Type: 
number
Examples
rosettajs.DateTime.netWorkDays("2013-12-04", "2013-12-07"); // returns 3
rosettajs.DateTime.netWorkDays("12/4/2013", "1/4/2014", "1/1/2014"); // returns 22

(inner) netWorkDaysIntl(startDate, endDate, weekendopt, holidaysopt) → {number}

Returns the number of whole workdays between two dates using parameters to indicate which and how many days are weekend days.

Parameters:
NameTypeAttributesDescription
startDateCustomDateType

A date that represents the first, or starting date of a given period.

endDateCustomDateType

A date that represents the last, or ending, date of the period.

weekendstring<optional>

Indicates the days of the week that are weekend days and are not included in the number of whole working days between start_date and end_date. Weekend is a weekend number or string that specifies when weekends occur.

Weekend number values indicate the following weekend days:

  • 1 Saturday, Sunday (Default value)

  • 2 Sunday, Monday

  • 3 Monday, Tuesday

  • 4 Tuesday, Wednesday

  • 5 Wednesday, Thursday

  • 6 Thursday, Friday

  • 7 Friday, Saturday

  • 11 Sunday only

  • 12 Monday only

  • 13 Tuesday only

  • 14 Wednesday only

  • 15 Thursday only

  • 16 Friday only

  • 17 Saturday only

    Weekend string values are seven characters long and each character in the string represents a day of the week, starting with Monday. 1 represents a non-workday and 0 represents a workday. Only the characters 1 and 0 are permitted in the string. Using 1111111 will always return 0.

    For example, 0000011 would result in a weekend that is Saturday and Sunday.

holidaysDateType | Array.<DateType><optional>

An optional range of one or more dates to exclude from the working calendar, such as state and federal holidays and floating holidays.

Returns:

The number of whole workdays between two dates.

Type: 
number
Examples
rosettajs.DateTime.netWorkDaysIntl("12/4/2013", "12/5/2013"); // returns 2
rosettajs.DateTime.netWorkDaysIntl("12/8/2013", "12/9/2013", 2); // returns 0

(inner) now() → {Date}

Returns the string representation of the current date and time. The Notes parameters, flags and serverNames, are not implemented in VoltFormula at this time.

See
Returns:

A date representation of the current date and time  and  www.oasis-open.org

Type: 
Date
Example
rosettajs.DateTime.now(); // returns Wed Jun 07 2023 12:26:36 GMT-0400 (Eastern Daylight Time)

(inner) second(dateOrDateList) → {NumberOrNumberList}

Extracts the number of the seconds from a specified Date. This function presumes that leap seconds never exist.

Parameters:
NameTypeDescription
dateOrDateListDateOrDateList

The date, as a string, Date object, or Array of Date objects, of the seconds you are trying to find.

See
Returns:

Number or Number list. Seconds portion (or list of seconds) of the given date.  and  www.oasis-open.org

Type: 
NumberOrNumberList
Examples
rosettajs.DateTime.second("1/1/1900"); // returns 0
rosettajs.DateTime.second("11/20/95 8:58:59"); // returns 59
rosettajs.DateTime.second(rosettajs.DateTime.date(95, 11, 20, 8, 58, 12)); // returns 12

(inner) textToTime(time_text) → {Date|DateRange|Array.<Date>|Array.<DateRange>}

Converts a text string to a Date value, where possible.

Parameters:
NameTypeDescription
time_textTextOrTextList

The strings you want to convert to a Date objects. "Today", "Tomorrow", and "Yesterday" are the only legal strings to use to represent relative dates.

See
Returns:

Date, Date range, or list thereof. The time_text, converted to a Date.

Type: 
Date | DateRange | Array.<Date> | Array.<DateRange>
Examples
rosettajs.Text.textToTime("05/12/23"); // Returns Date for 05/12/2023
rosettajs.Text.textToTime("Tomorrow"); // Returns Date for tomorrow

(inner) time(…args) → {number}

Constructs and returns a Date object from one of the following combination of Date parameters: ( hour, minute, second ), ( year, month, day, hour, minute, second ), or Date object or array of Date objects, as per the notes formula Time function parameters.

Parameters:
NameTypeAttributesDescription
args*<repeatable>

Date-time object or list of Dates, 6 Numbers representing the date-time, or 3 Numbers from 0 (zero) to 32767 representing the hour, minute, day. Any value greater than 23 will be divided by 24 and the remainder will be treated as the time value.

See
Returns:

A number representing time (as a fraction of a day) or Date-time object of the current time; display usually formatted in current locale.  and  www.oasis-open.org

Type: 
number
Examples
rosettajs.DateTime.time(1, 1, 1); // returns 0.04237268518518519 (open formula only)
rosettajs.DateTime.time(93, 12, 24, 12, 30, 40); // returns 1993-12-24 12:30:40.000 -0000
rosettajs.DateTime.time(rosettajs.DateTime.date(93, 12, 24, 12, 30, 40)); // returns 1993-12-24 12:30:40.000 -0000

(inner) timeMerge(dateStr, timeStr, timeZoneopt) → {DateOrDateList}

Builds a Date value from separate date, time, and time zone values.

Parameters:
NameTypeAttributesDescription
dateStrDateOrDateList

String, Date, or array of Strings or Dates. The date string or Date object representing the date you want to include in the new date-time value.

timeStrDateOrDateList

String, Date, or array of Strings or Dates. The time string or Date object representing the time you want to include in the new date-time value.

timeZonestring<optional>

String. Optional. Default is 'Z' for UTC. The canonical time zone value you want to apply to the new date-time value. You can use a Time zone field to create this value.

See
Returns:

A new Date value or Date list made up of the date, time, and zone supplied as function parameters.

Type: 
DateOrDateList
Example
rosettajs.DateTime.timeMerge("02/23/02", "17:45:00"); // returns '02/23/02 17:45:00'

(inner) timeToTextInZone(timeDate, timeZone, format) → {TextOrTextList}

Converts a Date value to a text string, incorporating time zone information.

Parameters:
NameTypeDescription
timeDateDateOrDateList

Time-date value or time-date list. The time-date value or values to be converted.

timeZonestring

Canonical time zone value. You can derive a time zone value using a Notes® Time zone field.

formatstring

Optional. String consisting of one or more format specifiers.

See
Returns:

The time-date value converted to a string.

Type: 
TextOrTextList
Example
rosettajs.DateTime.Text.timeToTextInZone("02/26/2002 03:06 PM EST", "Z=9$DO=1$DL=4 1 1 10-1 1$ZX=3$ZN=Alaskan", "D2T1S3"); // Returns "02/26/2002"

(inner) timeValue(timeText) → {number}

Converts a time in the form of text to a serial number.

Parameters:
NameTypeDescription
timeTextstring

The time represented by a text string.

See
Returns:

The decimal number of the time represented by a text string. The decimal number is a value ranging from 0 (zero) to 0.99988426, representing the times from 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 P.M.).

Type: 
number
Example
rosettajs.DateTime.timeValue("1/1/1900 12:00:00"); // returns ~ 0.5

(inner) timeZoneToText(timezone, formatopt) → {TextOrTextList}

Converts a canonical time zone value to a human-readable text string.

Parameters:
NameTypeAttributesDescription
timezoneTextOrTextList

Canonical time zone value or list thereof. Use a Notes® Time zone field to create a time zone value.

formatstring<optional>

String consisting of one or more of the following format specifiers:

  • S = Short time zone string,
  • A = Alias for local time zone. For example, if the zone is the same as the zone in which the system is running, returns: "Local time".
See
Returns:

The time-date value converted to a string. If you do not include a format specifier, a long time zone label is returned.

Type: 
TextOrTextList
Examples
rosettajs.Text.timeZoneToText("Z=9$DO=1$DL=4 1 1 10 -1 1$ZX=25$ZN=America/Anchorage", "S"); // returns "GMT-8 AKDT" (when DST is in effect)
rosettajs.Text.timeZoneToText("Z=5$DO=1$DL=4 1 1 10 -1 1$ZX=25$ZN=America/New_York", "SA"); // returns "Local time" (when DST is in effect)

(inner) today() → {Date}

Returns today's date.

See
Returns:

The date object for the current date and time.  and  www.oasis-open.org

Type: 
Date
Example
rosettajs.DateTime.today(); // returns Wed Jun 07 2023 12:26:36 GMT-0400 (Eastern Daylight Time)

(inner) tomorrow() → {Date}

Returns the time-date value that corresponds to tomorrow's date.

See
Returns:

Date object. Tomorrow's date.

Type: 
Date
Example
rosettajs.DateTime.tomorrow(); // returns '6/7/2024' if today is June 6th, 2024

(inner) weekday(dateOrDateList, returnTypeopt) → {number}

Extracts the day of the week from a date; if text, uses current locale to convert to a date. Returns a number that identifies the day.

Parameters:
NameTypeAttributesDefaultDescription
dateOrDateListDateOrDateList

The date

returnTypenumber<optional>
1

A number that determines the type of return value. The default is 1.

  • 1 Numbers 1 (Sunday) through 7 (Saturday)
  • 2 Numbers 1 (Monday) through 7 (Sunday)
  • 3 Numbers 0 (Monday) through 6 (Sunday)
  • 11 Numbers 1 (Monday) through 7 (Sunday)
  • 12 Numbers 1 (Tuesday) through 7 (Monday)
  • 13 Numbers 1 (Wednesday) through 7 (Tuesday)
  • 14 Numbers 1 (Thursday) through 7 (Wednesday)
  • 15 Numbers 1 (Friday) through 7 (Thursday)
  • 16 Numbers 1 (Saturday) through 7 (Friday)
  • 17 Numbers 1 (Sunday) through 7 (Saturday)
See
Returns:

The day of the week of a given date as a number from 1 through 7. (default)  and  www.oasis-open.org

Type: 
number
Examples
rosettajs.DateTime.weekday(2958465); // returns 6 (open formula only)
rosettajs.DateTime.weekday(rosettajs.DateTime.date(1900, 0, 31)); // returns 4
rosettajs.DateTime.weekday([rosettajs.DateTime.date(95, 11, 20, 8, 58, 12), rosettajs.DateTime.date(95, 11, 21, 8, 58, 12)]); // returns [2, 3]

(inner) weekNum(date, return_typeopt) → {number}

Converts a date to a number representing where the week falls numerically with a year.

There are two systems used for this function:

  • System 1 The week containing January 1 is the first week of the year, and is numbered week 1.
  • System 2 The week containing the first Thursday of the year is the first week of the year, and is numbered as week 1. This system is the methodology specified in ISO 8601, which is commonly known as the European week numbering system.
Parameters:
NameTypeAttributesDescription
dateCustomDateType

A date within the week.

return_typenumber<optional>

Optional. A number that determines on which day the week begins. The default is 1.

  • 1 Sunday, System 1 (Default value)
  • 2 Monday, System 1
  • 11 Monday, System 1
  • 12 Tuesday, System 1
  • 13 Wednesday, System 1
  • 14 Thursday, System 1
  • 15 Friday, System 1
  • 16 Saturday, System 1
  • 17 Sunday, System 1
  • 21 Monday, System 2
See
Returns:

The week number of given date.

Type: 
number
Example
rosettajs.DateTime.weekNum("2/1/1909", 2); // returns 6

(inner) workDay(startDate, days, holidaysopt) → {Date}

Returns the date before or after a specified number of workdays.

Parameters:
NameTypeAttributesDescription
startDateCustomDateType

A date that represents the first, or starting date of a given period.

daysnumber

The number of nonweekend and nonholiday days before or after start_date. A positive value for days yields a future date; a negative value yields a past date.

holidaysDateType | Array.<DateType><optional>

An optional range of one or more dates to exclude from the working calendar, such as state and federal holidays and floating holidays.

See
Returns:

The date before or after the specified number of workdays.

Type: 
Date
Examples
rosettajs.DateTime.workDay("1/1/1900", 1); // returns 1/2/1900
rosettajs.DateTime.workDay("1/1/1900", 2, "1/2/1900"); // returns 1/4/1900

(inner) workDayIntl(startDate, days, weekendopt, holidaysopt) → {Date}

Returns the date before or after a specified number of workdays using parameters to indicate which and how many days are weekend days.

Parameters:
NameTypeAttributesDescription
startDateCustomDateType

A date that represents the first, or starting date of a given period

daysnumber

The number of nonweekend and nonholiday days before or after start_date. A positive value for days yields a future date; a negative value yields a past date.

weekendstring | number<optional>

Indicates the days of the week that are weekend days and are not considered working days. Weekend is a weekend number or string that specifies when weekends occur.

Weekend number values indicate the following weekend days:
  • 1 Saturday, Sunday (Default value)

  • 2 Sunday, Monday

  • 3 Monday, Tuesday

  • 4 Tuesday, Wednesday

  • 5 Wednesday, Thursday

  • 6 Thursday, Friday

  • 7 Friday, Saturday

  • 11 Sunday only

  • 12 Monday only

  • 13 Tuesday only

  • 14 Wednesday only

  • 15 Thursday only

  • 16 Friday only

  • 17 Saturday only

    Weekend string values are seven characters long and each character in the string represents a day of the week, starting with Monday. 1 represents a non-workday and 0 represents a workday. Only the characters 1 and 0 are permitted in the string. Using 1111111 will always return 0.

    For example, 0000011 would result in a weekend that is Saturday and Sunday.

holidaysDateType | Array.<DateType><optional>

An optional set of one or more dates that are to be excluded from the working day calendar. Holidays shall be a range of cells that contain the dates, or an array constant of the serial values that represent those dates. The ordering of dates or serial values in holidays can be arbitrary.

Returns:

The date and time that was calculated before or after the given date.

Type: 
Date
Example
rosettajs.DateTime.workDay.intl("1/1/1905", 1, 2); // returns 1/3/1905

(inner) year(dateOrDateList) → {NumberOrNumberList}

Extracts the number of the month from the specified date.

Parameters:
NameTypeDescription
dateOrDateListDateOrDateList

The date, as a string, Date object, or Array of Date objects of the year you are trying to find.

See
Returns:

Number or Number list. Year portion (or list of days) of the date (or list of dates).  and  www.oasis-open.org

Type: 
NumberOrNumberList
Examples
rosettajs.DateTime.year(2958465); // returns 1995 (open formula only)
rosettajs.DateTime.year(new Date(1900, 0, 1)); // returns 1900

(inner) yearFrac(startDate, endDate, basisopt) → {number}

Returns the year fraction representing the number of whole days between start_date and end_date.

Parameters:
NameTypeAttributesDefaultDescription
startDateCustomDateType

A date that represents the first, or starting date of a given period.

endDateCustomDateType

A date that represents the last, or ending, date of the period.

basisnumber<optional>
0

The type of day count basis to use:

  • 0 US (NASD) 30/360 (Default value)
  • 1 Actual/actual
  • 2 Actual/360
  • 3 Actual/365
  • 4 European 30/360
See
Returns:

The year fraction of whole days between given dates.

Type: 
number
Examples
rosettajs.DateTime.yearFrac("1/31/1900", "3/31/1900", 0); // returns ~ 0.16666666666666666
rosettajs.DateTime.yearFrac("1/1/1904", "1/1/1905", 1); // returns 1

(inner) yesterday() → {Date}

Returns the time-date value that corresponds to yesterday's date.

See
Returns:

Date object. Yesterday's date.

Type: 
Date
Example
rosettajs.DateTime.yesterday();  // returns '6/5/2024' if today is June 6th, 2024

(inner) zone(dateOrDateList) → {NumberOrNumberList}

Returns the time zone setting of the current computer or of a time-date value, and indicates if daylight-saving time is observed. The time zone is represented as the number of hours that must be added to the time-date to convert it to Greenwich Mean Time.

Parameters:
NameTypeDescription
dateOrDateListDateOrDateList

Date or date list. Optional. The date whose zone you want to know. You must specify both a date; otherwise, @Zone returns 0.

See
Returns:

Number or number list. The time zone, followed by a period, followed by a flag indicating daylight-saving time.

Type: 
NumberOrNumberList
Example
rosettajs.DateTime.zone([1/26/94 11:00 AM]); // returns 5 if in EST