NotesDateRange (JavaScript)

Represents a range of dates and times.

Creation

To create a new NotesDateRange object, use createDateRange in NotesSession. To initialize the object, do one of the following:
  • Assign values to the createDateRange parameters.
  • Assign values to StartDateTime and EndDateTime.
  • Assign a string value that represents a date range to Text. This value consists of two string representations of date-time values separated by a hyphen (for example, "01/01/11 - 01/02/11").

Usage

When you assign StartDateTime or EndDateTime, its value replaces the corresponding value in Text, and vice versa.

Examples

This computed field creates a date-time range from two date-time values and returns its text value.
var doc:NotesDocument = currentDocument.getDocument();
var created:NotesDateTime = doc.getCreated();
var last:NotesDateTime = doc.getLastAccessed();
var range:NotesDateRange = session.createDateRange(created, last);
return "Life span of this document: " + range.getText()
This computed field creates a date-time range, sets its start and end values from two date-time values, and returns its text value.
var doc:NotesDocument = currentDocument.getDocument();
var created:NotesDateTime = doc.getCreated();
var last:NotesDateTime = doc.getLastAccessed();
var range:NotesDateRange = session.createDateRange();
range.setStartDateTime(created);
range.setEndDateTime(last);
return "Life span of this document: " + range.getText()
This computed field creates a date-time range from two Date values and returns its text value.
var doc:NotesDocument = currentDocument.getDocument();
var created:Date = doc.getCreated().toJavaDate();
var last:Date = doc.getLastAccessed().toJavaDate();
var range:NotesDateRange = session.createDateRange(created, last);
return "Life span of this document: " + range.getText()
This computed field creates a date-time range, sets its text value, and returns dates based on its start and end values. Also returned is the common name of the parent session.
var doc:NotesDocument = currentDocument.getDocument();
var created:string = doc.getCreated().getLocalTime();
var last:string = doc.getLastAccessed().getLocalTime();
var range:NotesDateRange = session.createDateRange();
range.setText(created + " - " + last);
//return range.getText()
return "Created on " + 	range.getStartDateTime().getDateOnly() +
	", last accessed on " + range.getEndDateTime().getDateOnly() +
	", current user " + range.getParent().getCommonUserName()