Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot compare string with date format #174

Open
imqishi opened this issue Apr 4, 2023 · 0 comments
Open

cannot compare string with date format #174

imqishi opened this issue Apr 4, 2023 · 0 comments

Comments

@imqishi
Copy link

imqishi commented Apr 4, 2023

exp, _ := govaluate.NewEvaluableExpression("create_time >= '2023-04-03 00:00:00'")
ret, err := exp.Evaluate(map[string]interface{}{
    "create_time": "2023-04-04 00:00:00",
})
fmt.Println(ret, err)

return
<nil> Value '2023-04-04 00:00:00' cannot be used with the comparator '>=', it is not a number

but if replace create_time with string '2023-04-04 00:00:00' is ok, so is the only way to make it by trans string-date to timestamp then compare integers?


well, I see this may solve this: https://github.com/Knetic/govaluate/pull/87/files/38d806c0a2f11d7be7da7752361f6850f9fd824d

but still have one question, why time-format string will be parsed to float64 not int64?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant