# Discussions

View Only

## I need a formula for a certain time of the month to equal yes or no.

• #### 1.  I need a formula for a certain time of the month to equal yes or no.

Posted 08-06-2018 17:07
I need a formula stating if date created occurred between the  1st and the 14th, yes is the value in the field.

• #### 2.  RE: I need a formula for a certain time of the month to equal yes or no.

Posted 08-06-2018 17:39
Try this

var number DayNumber = Day(ToDate([Date Created]));

IF(\$DayNumber >=1 and \$DayNumber <= 14,"yes")

• #### 3.  RE: I need a formula for a certain time of the month to equal yes or no.

Posted 08-06-2018 18:27
Thank you, it worked. How can I add if it is from the 15th to the end of the month, it is a "no"? I thought I had the option for a default to No, but it doesn't allow me to do that.

• #### 4.  RE: I need a formula for a certain time of the month to equal yes or no.

Posted 08-06-2018 18:35
You can change the IF to read like this.

IF(\$DayNumber >=1 and \$DayNumber <= 14,"yes", "no")

but that would mean that if that field is on the form in Add modem, then the [Date Created] field will be null as the record has not yet been created and yet the value would calculate to no and would then maybe change to yes when saved, which would be confusing for users.

So alternative is to change it to this

IF(
\$DayNumber >=1 and \$DayNumber <= 14,"yes",
\$DayNumber >=15n "no")

That way it would be blank until the record was initially saved.

If you want to get fancier with the formula there is also a way to make it work in Add mode by changing the whole formula to this

var number DayNumber = IF(IsNull([Date Created], Day(Today()),  Day(ToDate([Date Created])));

IF(\$DayNumber >=1 and \$DayNumber <= 14,"yes", "no")