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

BALAJI40
Mega Sage

Just tell me if i am correct or wrong,



The cost plan table date should be in between The fiscal periods are in the fiscal_period table. Just tell me


tekivijay
Giga Contributor

No Balaji



The Date on the custom table (Expense_lines) which is in   date/time format should fall between the fiscal period in the cost plan table



Ex:


On the custom table I have a date : 2017-04-19 00:00:00



This should fall under fy17-Jan and fy17-Apr.   In the cost plan table if there is an entry for that time period it has to get that



Vijay


This is clear.



One more question that,


The Date on the custom table (Expense_lines) which is in   date/time format should fall between the fiscal period in the cost plan table



How the expense_lines and cost plan table are related? tell me this one we can write the script based on that. one more thing tell me if you need the script based on onChange ?????


tekivijay
Giga Contributor

The Expense lines table has a Project no which is related to Oracle Project no (custom field) in the pm_project table.   And the Pm_project table project no( is related to the cost plan task



var relOracleProjectSysId='';


                              var   relOracleProject=new GlideRecord('cmn_cost_center');


                                relOracleProject.addQuery('code',current.u_project_no);


                                relOracleProject.query();


                              if( relOracleProject.next())


                                                              {


                                                                                             


                                                              relOracleProjectSysId= relOracleProject.sys_id;


                              }


                             


                             


                              var relProjectsysId='';


                              var relProject=new GlideRecord('pm_project');


                              relProject.addQuery('u_oracle_project_no',relOracleProjectSysId);


                              relProject.query();


                              if(relProject.next())


                                                              {


                                                                                             


                                                              relProjectsysId=relProject.sys_id;


                              }


                              var costPlan = new GlideRecord('cost_plan');


                              costPlan.addQuery('resource_type',current.u_cost_types);


                              costPlan.addQuery('task',relProjectsysId);


                              costPlan.query();



This is how i am relating. As there is a second part to this code, I have finished that part of the code but I am not able to get a login or script for this part