--
Hi everyone,I used var currentDate = new Date(); to get the "current date". I now want to use the current date var to create a "7 days ago" variable.For example, the current date is 6/18/2020. 7 days ago would be 6/11/2020. I want the variable to do this automatically.I tried looking this up and there wasn't a clear answer as to how to do this. Does anyone know?My date is formatted as "MM/dd/yyyy".
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/ff4c0dbb-4a98-468b-89db-30d3d9f40f28o%40googlegroups.com.
Hi Jorge,Would it be:
var currentDate = new Date();
var nDays = 7;var daysBefore = currentDate - 1000 * 60 * 60 * 24 * nDays;
var StartDate = new Date(daysBefore);
Logger.log(StartDate);And now I can pass StartDate into an API call by using that variable, which is the 7 days ago variable?
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/081b9e18-4818-4b44-a0e0-4fe094659bb7o%40googlegroups.com.
Oh I see - disregard my last message. I have to call the function to be able to use this part. And it'll make it quicker I bet.Do you know how I can make the function you gave me universal? Bc I will be using the dateToSend variable in many different functions.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/8bb917b3-118e-4645-8474-756557892cd3o%40googlegroups.com.