defining months to use in calculation | Community
Skip to main content
ReluctantProgrammer
Level 4
July 19, 2022
Solved

defining months to use in calculation

  • July 19, 2022
  • 1 reply
  • 1433 views

Trying to take a range of month/date to utilize in calculation below...

 

var d = new Date(this.rawValue);
YearTraveled.rawValue = d.getYear()+1900

 

if (this.resolveNode("YearTraveled").rawValue == "2020") {
this.resolveNode("TravelReimbursement").rawValue = ".575";
}
if (this.resolveNode("YearTraveled").rawValue == "2021") {
this.resolveNode("TravelReimbursement").rawValue = ".560";

 

I want the next action to say...

if MonthTraveled is (July 2022 thru December 2022)

this.resolveNode("TravelReimbursement").rawValue = ".625";

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by MorisMonk

Try this

var d = new Date(this.rawValue);
YearTraveled.rawValue = d.getFullYear();
MonthTraveled.rawValue = d.getMonth() + 1;
TravelReimbursement.rawValue = "";

if (YearTraveled.rawValue == "2020") {
	TravelReimbursement.rawValue = ".575";
	
} else if (YearTraveled.rawValue == "2021") {
	TravelReimbursement.rawValue = ".560";
	
} else if (YearTraveled.rawValue == "2022") {
	if ((MonthTraveled.rawValue >= 7) && (MonthTraveled.rawValue <= 12)) {
		TravelReimbursement.rawValue = ".625";
	}
}

1 reply

MorisMonkAccepted solution
Level 4
July 20, 2022

Try this

var d = new Date(this.rawValue);
YearTraveled.rawValue = d.getFullYear();
MonthTraveled.rawValue = d.getMonth() + 1;
TravelReimbursement.rawValue = "";

if (YearTraveled.rawValue == "2020") {
	TravelReimbursement.rawValue = ".575";
	
} else if (YearTraveled.rawValue == "2021") {
	TravelReimbursement.rawValue = ".560";
	
} else if (YearTraveled.rawValue == "2022") {
	if ((MonthTraveled.rawValue >= 7) && (MonthTraveled.rawValue <= 12)) {
		TravelReimbursement.rawValue = ".625";
	}
}
ReluctantProgrammer
Level 4
July 20, 2022

Good morning.

 

This works up until the last condition.  Probably something small I'm missing.  Is there a way I can share my file for you to review?

Level 4
July 20, 2022

Have you got a field named MonthTraveled ?  
You could just use variables as well.

Actually not sure what the preferred method of sharing files is on this forum.