• 0

# Table field Formula help

## Question

I want to use a case formula where the Date field contains the same info them 1 else 0.

I trued this one, but it does not work as expected.

Case
WHEN ([@field:Data]) = ([@field:Data]) THEN '1'
ELSE
'0'
END

Date column contains:  dd/mm/year/ hours:minutes:seconds:  The above formula just match for  dd/mm/year/ and it does not consider time hours:minutes:seconds ( I would expected to have 1,1,0,0,0,0,0)

## Recommended Posts

• 0

Hi there!

If the goal is to check the 2 date fields if they are matched it displays 1 and 0 if not. You can try to check this code:

Case
WHEN CONVERT(varchar,[@field:XXXX],106) =CONVERT(varchar,[@field:XXXX],106) THEN '1'
ELSE
'0'
END

Just change the field names and table names depending on the field that you are using.

I hope this is useful.

##### Share on other sites

• 0

If you want to check if day, month and year matches you may use the formula below and change the Date field.

```CASE
WHEN MONTH([@field:Date]) = MONTH([@field:Date2]) AND YEAR([@field:Date]) = YEAR([@field:Date2]) AND DAY([@field:Date]) = DAY([@field:Date2]) THEN '1 1 1'
WHEN YEAR([@field:Date]) = YEAR([@field:Date2]) THEN '0 0 1'
WHEN MONTH([@field:Date]) = MONTH([@field:Date2]) THEN '0 1 0'
ELSE '0 0 0'
END```

In this formula follows dd/mm/yyyy format and it checks if it matches day, month, and year.

So if datefield1 and datefield two only matches month it would return '0 1 0'

Hope this helps!

##### Share on other sites

• 0

Hello everyone, just wanted to share that you can change the format for the converted date as well by changing the number CONVERT(varchar,[@field:XXXX],106) to the ones below.

##### Share on other sites

• 0

Hello!

It seems that your formula is working even if the goal only is to check the 2 date fields if they are matched (1) or not (0). Perhaps could you please elaborate more on the expected which is to have 1,1,0,0,0,0,0? You may refer to Function Reference for other functions that you can use in the formula:

https://howto.caspio.com/function-reference/

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.