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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category