Function Problems

Return 1 or 0 in WPS Office Excel Based on Date Criteria

Steve KSteve K Nov 13, 2026 869 views

Question details

The user needs a formula to return 1 or 0 for visit dates by comparing each visit date with a specified start date, with the condition taking effect at the next visit.

Return 1 or 0 in WPS Office Excel Based on Date Criteria
Product
WPS Office Excel
Device & OS
not provided
Scenario
Comparing visit dates against a start date and outputting a numeric 1 or 0 result for each visit.
Observed behavior
The user wants the formula to return a numeric 1 or 0 instead of TRUE or FALSE based on the date comparison.
Before you start

Verify that the visit dates and the reference start date are real Excel date cells rather than text; otherwise the comparison may not calculate correctly. Decide whether the condition should use < or <= based on whether the start date itself is included.

Solution 1Recommended

Use a double unary comparison to return 1 or 0 for a date condition

Use this compact formula when you need to convert the TRUE or FALSE result of a date comparison into a numeric 1 or 0.

WPS Office Excel evaluates A7<B2 as TRUE or FALSE. The double unary operator -- converts TRUE to 1 and FALSE to 0, so the result can be used directly in sums, counts, or other calculations.

1
Select the formula cell

Click the cell where you want the 1 or 0 result to appear.

2
Enter the comparison formula

Type =--(A7<B2) and press Enter, replacing A7 with the visit date cell and B2 with the start date cell.

3
Fill the formula as needed

Drag the fill handle down or across to apply the formula to the other visit dates.

Use a double unary comparison to return 1 or 0 for a date condition
Date logic can be reversed easily: Use =--(A7>=B2) if you need a different cutoff, such as returning 1 for dates on or after the start date.
WPS Office Excel formula

Create 1/0 Date Criteria Formulas in WPS Office Excel

In WPS Office Excel, use =--(A7<B2) or =--(TRANSPOSE(A7:A10)<B2:E2) to turn date comparisons into numeric 1/0 results. Open your workbook, select the result cell, enter the formula, and fill it across the visit dates.

  1. 1. Open WPS Office Excel: Launch WPS Office and open the workbook that contains your visit dates and start date.
  2. 2. Select a result cell: Click the cell where you want the 1 or 0 result to appear.
  3. 3. Enter the date comparison formula: Type =--(A7<B2) and press Enter to convert the date comparison result to a numeric 1 or 0.
  4. 4. Apply the formula to the remaining data: Use the fill handle or a TRANSPOSE array formula to extend the calculation to your other visit dates.
Use the same double unary date comparison formula as in Microsoft Excel to get 1 or 0 resultsFull compatibility with .xlsx and .xls workbooks when migrating from Microsoft OfficeFree, lightweight spreadsheet editing without changing your existing date formulasFamiliar ribbon interface makes the formula bar and fill handle easy to find
microsoft office alternative - wps office

Frequently Asked Questions

What does the double unary -- do in =--(A7<B2)?

The double unary converts the TRUE or FALSE result of the date comparison into 1 or 0, so the result can be used in numeric calculations.

How do I return 1 if a visit date is after the start date in WPS Office?

Use =--(A7>B2) in WPS Office Excel, replace A7 with the visit date cell and B2 with the start date cell, then press Enter.

How can I compare a vertical date list with horizontal criteria cells?

Use =--(TRANSPOSE(A7:A10)<B2:E2) and confirm it as an array formula if required. This aligns the transposed visit dates with the horizontal date row.

Why does my date comparison return the wrong 1 or 0?

Check that all date cells contain real dates and not text, and confirm whether you need < or <= and whether an end date should also be included in the rule.

Does WPS Office support the same date formulas as Microsoft Excel?

Yes, WPS Office Excel supports the same comparison and TRANSPOSE formulas in .xlsx and .xls workbooks.