- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2025 10:04 PM - edited 05-25-2025 10:05 PM
I am trying to set a flow variable that I've called - next_audit_date
What I want to do is to set the value of the flow variable to be june 30 of the year that that date comes next on.
EG: if it is 20 may, then set date as June 30, current year (2025)
If it is 10 July, then set the date to be June 30 the next year (2026)
Anyone able to help please?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2025 10:41 PM
Hi @Bidduam,
This may need bit of testing but try the following code to set your flow variable:
var nowGD =new GlideDate();
var year = nowGD.getYearNoTZ();
if( !((nowGD.getDayOfMonthNoTZ()) < 30 && (nowGD.getMonthNoTZ() <= 6)))
{
year ++;
}
var auditGD = new GlideDate();
auditGD.setDisplayValue(year + '-06-15');
return auditGD;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2025 10:54 PM
Hi @Bidduam
Try the below script.
var today = new GlideDateTime();
var currentYear = today.getYear();
var june30th = new GlideDateTime();
june30th.setValue(currentYear+'-06-30'); // set to a known date for comparison
gs.print(june30th);
if (today.before(june30th)) {
var june30thThisYear = new GlideDateTime();
june30thThisYear.setValue(currentYear + '-06-30');
// set the custom variable value
return june30thThisYear;
} else {
var june30thNextYear = new GlideDateTime();
june30thNextYear.setValue((currentYear + 1) + '-06-30');
// set the custom variable value
return june30thNextYear;
}Output:
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2025 10:18 PM
@Bidduam wrote:I am trying to set a flow variable that I've called - next_audit_date
What I want to do is to set the value of the flow variable to be june 30 of the year that that date comes next on.
EG: if it is 20 may, then set date as June 30, current year (2025)
If it is 10 July, then set the date to be June 30 the next year (2026)
Anyone able to help please?
To set your next_audit_date flow variable to June 30 of the relevant year, compare the current date to June 30 of the current year. If today's date is on or before June 30, the next_audit_date will be June 30 of the current year. If today's date is after June 30, then the next_audit_date will be June 30 of the next year. This logic ensures you always pick the upcoming June 30.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2025 10:41 PM
Hi @Bidduam,
This may need bit of testing but try the following code to set your flow variable:
var nowGD =new GlideDate();
var year = nowGD.getYearNoTZ();
if( !((nowGD.getDayOfMonthNoTZ()) < 30 && (nowGD.getMonthNoTZ() <= 6)))
{
year ++;
}
var auditGD = new GlideDate();
auditGD.setDisplayValue(year + '-06-15');
return auditGD;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2025 10:54 PM
That appears to work perfectly thank you 🙂
Of course I can't test if it works after 30 June currently, but certainly works for now. Thanks again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2025 10:54 PM
Hi @Bidduam
Try the below script.
var today = new GlideDateTime();
var currentYear = today.getYear();
var june30th = new GlideDateTime();
june30th.setValue(currentYear+'-06-30'); // set to a known date for comparison
gs.print(june30th);
if (today.before(june30th)) {
var june30thThisYear = new GlideDateTime();
june30thThisYear.setValue(currentYear + '-06-30');
// set the custom variable value
return june30thThisYear;
} else {
var june30thNextYear = new GlideDateTime();
june30thNextYear.setValue((currentYear + 1) + '-06-30');
// set the custom variable value
return june30thNextYear;
}Output:
Regards,
Siva
