Skip to Content Skip to Menu

[SOLVED] Using cb:if to check whether a date type userfield is empty

  • wbuk
  • wbuk
  • OFFLINE
  • Posts: 116
  • Thanks: 8
  • Karma: 1
7 years 4 months ago - 7 years 4 months ago #296484 by wbuk
Wonder if you could tell us what's wrong.

We have a userfield with date type.

We want it to display a message if it's empty, and to display the date if it's not.
Code:
[cb:if cb_creationdate=""]Contact us to create a Nutrition Plan. [cb:else]Nutrition Plan created on [value].[/cb:else] [/cb:if]

However, it does not seem to work, the first statement (Contact us..) does not display at all while the second statement displays regardless of whether the field has a value or not.

Web Buster UK Ltd
Last edit: 7 years 4 months ago by krileon. Reason: Added [SOLVED] tag to subject

Please Log in or Create an account to join the conversation.

  • wbuk
  • wbuk
  • OFFLINE
  • Posts: 116
  • Thanks: 8
  • Karma: 1
7 years 4 months ago - 7 years 4 months ago #296485 by wbuk
It's okay, we solved our problem. It seems NULL for date should be 0000-00-00.

We changed it to code below and it worked.
Code:
[cb:if cb_creationdate="0000-00-00"]Contact us to create a Nutrition Plan. [cb:else]Nutrition Plan created on [value].[/cb:else] [/cb:if]

Web Buster UK Ltd
Last edit: 7 years 4 months ago by wbuk.
The following user(s) said Thank You: krileon

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum