Skip Navigation

[Resolved] Compare date values in custom field

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by Minesh 2 months, 2 weeks ago.

Assisted by: Minesh.

Author
Posts
#2748489

I have two custom DateTime fields and want to compare the date from field 1 with the value from field 2. If the values are different, an output should be generated. I have created the following query for this:

[wpv-conditional if="( $(wpcf-begin style='text' format='Ymd') ne $(wpcf-end style='text' format='Ymd') )"]
- [types field='end' style='text' format='d. F Y'][/types]
[/wpv-conditional]

Unfortunately there is no output. What am I doing wrong?

#2748557

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Types custom date field stores date value as Unix Timestamp to database.

What if you try to use the following code to compare the two dates.

	
[wpv-conditional if="('[types field='begin' output='raw'][/types]' ne '[types field='end' output='raw'][/types]' )"]
- [types field='end' style='text' format='d. F Y'][/types]
[/wpv-conditional]

More info:
- https://toolset.com/documentation/legacy-features/views-plugin/#conditional-output-in-views

#2748650

If I check the values as raw output, the output is still displayed for the identical date with different times. That's why my idea was to format the values in the query. Unfortunately, I cannot get a result with this solution. Any ideas?

#2748652

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share problem URL and admin access details and tell me how exactly you want to compare the both date fields and what is your expected result.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2749876

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now: hidden link

To your view's template, I've adjusted the code to display date only when start and end date is different as given under:
=> hidden link

    [wpv-conditional if="( '[types field='beginn' style='text' format='d. F Y'][/types]' ne '[types field='ende' style='text' format='d. F Y'][/types]' )"]
       [types field='ende' style='text' format='d. F Y'][/types]
    [/wpv-conditional]

Can you please confirm it works as expected.

#2749919

It works perfectly. Many thanks for the support.