将UNIX时间戳转换为Datatime SQL查询
我有这样的查询,
select * from my_tabel where created_at >= 1655546400000
我想将此查询提供给最终用户,并且数据库中的Ceraetd_at字段是UNIX TIMESTAMP,他不知道Unix Timestamp,因此他应该能够将其更改为自定义DateTime。我想将其更改为此查询,因为此查询适用于最终用户
select * from my_tabel where created_at >= "2022-06-18 10:00:00"
I have query like this
select * from my_tabel where created_at >= 1655546400000
I want to give this query to the end-user and the ceraetd_at field in the database is Unix timestamp and he doesn't know Unix timestamp so he should be able to change it to custom DateTime. I want to change it to this query because this query is readable for end-user
select * from my_tabel where created_at >= "2022-06-18 10:00:00"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现这很有帮助,您可以尝试一下。转换后,您可以根据需要使用值。
有关 dateadd 函数。
在您的问题更新之后,阅读您的问题后我已经了解了什么是,您的用户想将日期与
ceraetd_at
字段进行比较,因为UNIX时间没有给出有关常规日期格式的太多详细信息,那就是您想要转换ceraetd_at
,以便他们可以比较或运行查询。因此,您可以这样做以下操作:
I have found this very helpful, you can try it. After converting you can use the value however you want.
More details about DATEADD function.
After the update of your question, What I have understood after reading your question is, that your user wants to compare date with
ceraetd_at
field, as UNIX time does not give much details about regular date format, that's you want to convert theceraetd_at
, so that they can compare or run their query.So for doing that you can do like below: