Condition: If field A is qual field B

By: Jan Theofel | Asked: 02/12/2023
ForumsCategory: How-toCondition: If field A is qual field B
Jan Theofel asked 2 years ago
Hello! is it possible to compare a field not to a given value but to another field in a view? Something link this: Date: [firstday][if firstday not_equal lastday] until [lastday][/if firstday] I tried it but it didn't work. Thanks!
Jan
3 Answers
Rob LeVineRob LeVine answered 2 years ago
Though I'm not sure what your use case is, it seems like you want to take advantage of the multiple conditionals as seen here. Instead of the hardocded values in the example, you can use the shortcode for the other field(s).
Jan Theofel answered 2 years ago
Hi Rob!
Thanks for multiple conditions. That's not what I need - but good to know.   I need the second thing: Not hardcode the values but using shortcode instead.
When I enter the shortcode for the field I want to compare with, I get the following code.
For better reading I replaces the IDs with the field names - but it does not work either.   I list events which last one or multiple days. If they only last one day i want to print "Date: d.m.Y" and if the last longer I want to print "Date: d.m.Y until d.m.Y". (German date format.)   This is the code I'm using for this:
Date: [firstday format="d.m.Y"][if firstday not_equal="[lastday]"] until [lastday format="d.m.Y"][/if firstday]
  It's output is always like this - no matter if the fields are equal or not:   Date: 26.02.2023″] until 28.02.2023   So the IF statement seems to be broken. But I don't see any syntax error there.   Jan
Jan Theofel answered 2 years ago
Support answered that date fields can not be compared like this.
They suggested to add a calculated field with the duration in days and use that field for the condition. This works fine.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right