使用CQL筛选器查询与当前日期相关的日期

huangapple go评论95阅读模式
英文:

Using CQL filter to query date relative to present

问题

我正在使用geoserver,并且想要按日期(WFS)筛选我的图层,
我有两列:Date_start和Date_end

我想要显示只有符合这个条件的要素:
Date_PRESENT > Date_start 且 Date_PRESENT < Date_end

其中Date_PRESENT是当前日期和时间。
我不想手动输入今天的日期,我想根据当前日期而无需调整CQL筛选。

根据有关时间谓词的文档,我可以接近实现:
https://docs.geoserver.org/latest/en/user/filter/ecql_reference.html#temporal-predicate
但我找不到如何获取当前日期的方法。

谢谢

英文:

I'm working with geoserver ,and i want to filter my layer by date (WFS),
i have two columns : Date_start and Date_end

i would like to display only feature that verify this condition :
Date_PRESENT >Date_start and Date_PRESENT<Date_end

where Date_PRESENT is the current date and time.
i dont wanna put today's date in manually,I want to do it based on the present without a need to adjust the CQL filter.

Following the docs regarding temporal predicates, I can get close:
https://docs.geoserver.org/latest/en/user/filter/ecql_reference.html#temporal-predicate
But i can't find how to get the current date

thanks

答案1

得分: 2

尝试使用 now() &gt; Date_Start and now() &lt; Date_End

详见完整的CQL函数参考链接:
https://docs.geoserver.org/stable/en/user/filter/function_reference.html#temporal-functions

英文:

Try with now() &gt; Date_Start and now() &lt; Date_End

See also the full CQL function reference:
https://docs.geoserver.org/stable/en/user/filter/function_reference.html#temporal-functions

huangapple
  • 本文由 发表于 2023年5月17日 17:42:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76270690.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定