Confiforms filter syntax - date calculations
Asked by Drew T:

I have a confiform that I'm trying to add css rules to some fields. I'm having trouble getting the expression correct to make it work.

I have 6 date fields:

- initial start (initStartDate)

- initial end date (initEndDate)

- Option 1 Start Date (opt1StartDate)

- Option 1 End Date (opt1EndDate)

- Option 2 Start Date (opt2StartDate)

- Option 2 End Date (opt2EndDate)

I'm trying to achieve three filters for css rules based on the initEndDate field.

1. if opt1StartDate AND opt2StartDate are empty AND initEndDate is greater than 180 days from Today, then background colour should be green.

2. if opt1StartDate AND opt2StartDate are empty AND initEndDate is less than 180 days from Today, then background colour should be orange

3. if opt1StartDate AND opt2StartDate are empty AND initEndDate is less than or equal to today then background colour should be red

I've tried the following approaches trying both timestamp and number of day values but haven't gotten it right yet. I believe from the docs that datetime intervals need to be done in milliseconds, but unsure if this is also the case for date values.

opt1StartDate:\[empty\] AND opt2StartDate:\[empty\] AND initEndDate.subtract(_today):\>180

opt1StartDate:\[empty\] AND opt2StartDate:\[empty\] AND initEndDate.subtract(_today):\>15552000000

opt1StartDate:\[empty\] AND opt2StartDate:\[empty\] AND (\[entry.initEndDate\]-_today):\>180

Appreciate any help to identify the issue.

Thanks

Drew


Answers:
author: Alex Medved _ConfiForms_
body: Hi [@Drew T](/t5/user/viewprofilepage/user-id/4734306)

Try the following

```
opt1StartDate:[empty] AND opt2StartDate:[empty] AND initEndDate:>[today]+180
```

or

```
opt1StartDate:[empty] AND opt2StartDate:[empty] AND initEndDate.substract(15552000000):>[entry._now]
```

Alex

comments: author: Drew T
body: Thanks [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) that did the job!


author: SKAdmin
body: [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) Any reason why none of these work? every date displays error.

Due is date field, formatted to yyyy-MM-dd

'ConfiForms Rules for Field Definition w/ condition !due\[empty\]

Validation Rule

* **due:\>\[today\]+14**
* **due:\>(\[entry._today.add(1209600000)\])**
* **due:\>(\[today\]+14)**
* **`due:>([entry.due.timestamp] +1209600000``)`**


author: Alex Medved _ConfiForms_
body: You need to define **that** in the condition, in addition to what you already have

For example

```
!due:[empty] AND due:>[today]+14
```

or

```
!due:[empty] AND due:>([entry._today.add(1209600000)])
```

Alex


author: SKAdmin
body: No such luck with either.

Seems to be a bigger issues, as the value is way off.

due in the ConfiForms Field Definition' Macro is a Date field type, since this is linked to the due date in Jira for issue creation.

Tried selecting 2/2/24

* Value '1706860800000' for 'Due Date' does not match the validation rules (due:\>(\[entry._today.add(1209600000)\])) set for this field

Can I just use the validation rule section in the ConfiForms Field Definition, or do I have to add ConfiForms Rules for Field Definition' Macro as well?


author: SKAdmin
body: If I try just a condition in ConfiForms Rules for Field Definition and no validations it lets all entries go through, even if i pick tomorrow.


author: Alex Medved _ConfiForms_
body: Please open a [support ticket](https://wiki.vertuna.com/display/VERTUNA/Support+Request+Form) with us. I recall there was a regression with a validation in few minor versions just recently. Might be related to this (has been fixed some time ago)


author: SKAdmin
body: Let me upgrade to the newest version and retest, that might be the problem. If not, I'll get a support ticket open.


author: Drew T
body: [@Alex Medved _ConfiForms_](https://community.atlassian.com/t5/user/viewprofilepage/user-id/781630) are you able to assist?


Tags: confiforms

confluence-server

server