like next_day is there a previous_day
# ask-stanley-ai
v
like next_day is there a previous_day
c
AI generated answer (using internal Slack threads):
In NetSuite, there isn't a built-in function like
next_day
for getting the previous day. However, you can achieve this using JavaScript or SuiteScript. Here is a simple example:
Copy code
javascript
const today = new Date();
const previousDay = new Date(today);
previousDay.setDate(today.getDate() - 1); 
log.debug('previousDay', previousDay);
This script creates a new Date object for the current date, then creates a copy of this date object and subtracts one day to get the previous day. For getting the previous 7 rolling days in a report, you can use a formula in a saved search. Here is an example:
Copy code
sql
CASE WHEN {createddate} BETWEEN ({today}-7) AND ({today}-1) THEN 1 ELSE 0 END
This formula checks if the
createddate
is between 7 days ago and yesterday. If it is, the formula returns 1, otherwise, it returns 0. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.806717157
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.805627
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.795512378
Please provide your feedback on this answer.