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.
Source: This article is based on Oracle's official NetSuite documentation.
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 General
- Payment Date Prediction Feature in NetSuite
Payment Date Prediction in NetSuite utilizes machine learning to enhance financial planning by predicting invoice payment dates.
- NetSuite Ship Central Enhancements for Packing & Shipping
NetSuite Ship Central features enhance packing and shipping operations for improved efficiency and accuracy.
- New Role Setup for NetSuite AI Connector Service in 2026.1
The 2026.1 release adds a new role requirement for the NetSuite AI Connector Service, streamlining custom tool development.
- Generative AI Features in NetSuite 2026.1
Discover new generative AI features in NetSuite 2026.1, enhancing reporting, search, predictions, and development productivity.
Advertising
Reach General Professionals
Put your product in front of NetSuite experts who work with General every day.
Sponsor This Category