Modules

filter

 

Objects/Functions

module (N/query)

SuiteScript 2.0

query.createRelativeDate(options)

{query}.createRelativeDate({dateId: {string*},value: {number*}})

N/query Module
query.createRelativeDate()
Method Description: Creates a query.RelativeDate object that represents a date relative to the current date. Use this method to create a query.RelativeDate object to use as part of a query condition. After you create a query.RelativeDate object, you can use it directly in the values parameter of Query.createCondition(options) or Component.createCondition(options). When you call this method, the options.dateId parameter determines the relative date that is created. The options.dateId parameter uses values from the query.DateId enum, and these values describe potential dates relative to the current date. Use them along with the options.value parameter to create a relative date. For example, to create a relative date that represents the date three weeks before the current date, call query.createRelativeDate(options) with an options.dateId value of query.DateId.WEEKS_AGO and an options.value value of 3. To create a relative date that represents the date three weeks after the current date, call query.createRelativeDate(options) with an options.dateId value of query.DateId.WEEKS_FROM_NOW and an options.value value of 3.
Returns: query.RelativeDate
Supported Script Types: Client and server scripts For more information, see SuiteScript 2.0 Script Types.
Governance: None
Module: N/query Module
Sibling Module Members: N/query Module Members
Since: 2019.1
Search NetSuite - https://system.netsuite.com/app/help/helpcenter.nl?search=query.createRelativeDate(options)

Example:

// Code Example 1
// Add additional code
//...
var myTransactionQuery = query.create({
type: query.Type.TRANSACTION
});

var myRelativeDate = query.createRelativeDate({
dateId: query.DateId.DAYS_AGO,
value: 5
});

myTransactionQuery.condition = myTransactionQuery.createCondition({
fieldId: 'trandate',
operator: query.Operator.WITHIN,
values: [query.RelativeDateRange.THREE_FISCAL_YEARS_AGO.start, myRelativeDate]
});
//...
// Add additional code

//SOURCE: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_1544108154.html