RelativeDate Object Members in SuiteScript for Queries
The RelativeDate object in SuiteScript allows querying with defined time intervals, enhancing data filtering capabilities.
The RelativeDate object in SuiteScript provides developers with the ability to use relative dates in query conditions, offering a dynamic way to filter records based on time intervals. This object, introduced in SuiteScript, supports a range of scripting needs and is essential for creating flexible and time-sensitive queries.
What is the RelativeDate Object?
A RelativeDate object allows you to represent a specific moment in time, facilitating the creation of query conditions through the use of operators such as query.Operator.AFTER, query.Operator.BEFORE, and query.Operator.WITHIN. This enhances your ability to filter data dynamically based on time.
How to Create a RelativeDate Object
To create a RelativeDate object, utilize the query.createRelativeDate(options) method. This method allows you to define various properties associated with the relative date.
RelativeDate Object Members
The RelativeDate object includes several useful members, each serving a unique purpose. Below are the available members:
| Member Name | Type | Description |
|---|---|---|
RelativeDate.dateId | string (read-only) | The ID of the relative date. |
RelativeDate.end | Object (read-only) | The end point of the relative date. |
RelativeDate.interval | Object (read-only) | The interval from RelativeDate.start to RelativeDate.end. |
RelativeDate.isRange | boolean (read-only) | Indicates if this is a range of dates or a specific moment in time. |
RelativeDate.start | Object (read-only) | The start point of the relative date. |
RelativeDate.value | number (read-only) | The value associated with the relative date. |
Supported Script Types
The RelativeDate object is available for Client and Server scripts, making it versatile for various scripting needs.
Example Code
Here is a syntax example showing how to create a RelativeDate object and use it in a query condition:
1// Create a relative date object for two weeks ago2var myEndDate = query.createRelativeDate({3 dateId: query.DateId.WEEKS_AGO,4 value: 25});6 7// Create a complex query condition using the relative date8var myComplexCondition = myQuery.createCondition({9 fieldId: 'trandate',10 operator: query.Operator.WITHIN,11 values: [query.RelativeDateRange.THREE_FISCAL_YEARS_AGO.start, myEndDate]12});Conclusion
The RelativeDate object significantly improves the ability to handle date-sensitive queries in SuiteScript, allowing developers to create flexible filters based on relative date calculations. Utilizing these robust features enhances query performance and the precision of data retrieval.
Key Takeaways
- The RelativeDate object is crucial for query conditions involving time.
- It supports both Client and Server script types.
- Members like
dateId,start, andendenhance functionality. - Flexible use of relative timing improves data interrogation efficiency.
Frequently Asked Questions (4)
What script types support the RelativeDate object in SuiteScript?
How do you create a RelativeDate object in SuiteScript?
What are the members of the RelativeDate object, and what do they represent?
Can the RelativeDate object be used to filter records based on time intervals in SuiteScript?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
