to check if a date falls in between two other dates.

tekivijay
Giga Contributor

Hi

Here is my situation

I have a custom table (expense lines) which has a Date field.   I need to check if the date falls between a specific fiscal period.   The fiscal periods are in the fiscal_period table.   the Fiscal Period would have periods like below

find_real_file.png

Once I get the fiscal period I need to validate if the said record in Expense lines matches the fiscal period in the cost plan table

find_real_file.png

Can someone help me with a script on this

Much appreciate

Vijay

12 REPLIES 12

Use this way, the validation for date is to check in between or not,



var dateValidation = false;



var apprDate = new GlideDateTime(approveDate);// approve start date
var compDate = new GlideDateTime(compareDate);//onChange date
var renDate = new GlideDateTime(renewalDate);// approve end date
var res1 = gs.dateDiff(apprDate.getDisplayValue(),compDate.getDisplayValue(),true);
var res2 = gs.dateDiff(compDate.getDisplayValue(),renDate.getDisplayValue(),true);
if (res1>0 && res2>0){
dateValidation = true;;
}
return dateValidation;

tekivijay
Giga Contributor

Let me try this and I will reply back


There is a Script Includes OOB called FiscalPeriodHelper. In that we have a method like this



fiscalPeriodForDate which accepts a dateTime. So you can get the Fiscal period for the corresponding DateTime from that. Will that be useful for you?        


tekivijay
Giga Contributor

Hi Arun



I am using the OOB Script include.   I had to make some changes but.   Thanks for pointing it out. Appreciate it.


Where is the OOB Script Include...Have the plugin enabled but do not see this script include.