Skip to content

[Bug] Incorrect type conversion while comparing a cell reference containing date as string literal and another string literal #6392

@pixelpanda16

Description

@pixelpanda16

Before you submit this issue, have you checked the following

  • Is this really a problem?
  • I have searched the Github Issues for similar issues, but did not find anything.

Affected packages and versions

0.10.14, 0.12.4, 0.14.0

Reproduction link

https://stackblitz.com/edit/univer-sheets-vite-cfpfg2nd?file=src%2Fmain.ts

Expected behavior

When comparing a cell reference containing "2025-01-01" as string literal(not a formatted number), and another string literal "2026-01-01"

=A1>="2026-01-01"

The expected output is FALSE,

Actual behavior

Univer always returns TRUE in such cases.

Diving deeper into the code it looks like Univer tries to interpret the RHS i.e "2026-01-01" as date, and hence while doing comparison does a comparison like

"2025-01-01" >= 4555

Whenever a string is compared against a number with >=, univer formula engine always returns TRUE.

This behavior is completely different from MS Excel, and Google Sheet, where they seem to do lexical comparison of the LHS and RHS.

Screenshot 1 -> Incorrect formula output
Image

Screenshot 2 -> Correct formula output when TEXT() function is used to skip automatic type conversion
Image

Screenshot 3 -> Correct formula output when TEXT() function is used to skip automatic type conversion
Image

System information

No response

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions