时间戳字符串到SQL中的时间戳

发布于 2025-02-08 19:07:21 字数 102 浏览 1 评论 0原文

日期数据从条纹start_date保存为字符串时间戳,例如“ 1652789095”。 现在,我想在过去12个月中使用此时间戳字符串表格过滤。 我应该怎么办 ? 如何使用此时间戳字符串过滤?

Date data saved from stripe start_date as string timestamp like "1652789095".
Now I want to filter with this timestamp string form last 12 months.
what should I do ?
how can I filter with this timestamp string?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清风疏影 2025-02-15 19:07:21

这些是一些示例 - 我敢肯定有很多选择可以使用。

转换为日期

select *
from Table
where 
  to_timestamp(cast(start_date as int)::date > date_add(now(), interval -1 year);

使用Unix Timestamps工作,

-- approx 1 year ago, by way of example
select * 
from Table
where
  start_date > '1621253095';

-- exactly one year ago, calculated dynamically
select * 
from Table 
where 
  start_date > 
    cast(unix_timestamp(date_add(now(), interval -1 year)) as varchar);

我不是一个MySQL的家伙,真的可以原谅任何语法错误,并根据需要修复SQL以在MySQL中工作。

资源:

postgresql:如何从Unix Epoch转换为迄今为止? /a>

https://www.postgresonline.com/article_pfriendly/3.html/3.html

These are some examples - I'm sure there are plenty of options that would work.

convert to date

select *
from Table
where 
  to_timestamp(cast(start_date as int)::date > date_add(now(), interval -1 year);

work with unix timestamps

-- approx 1 year ago, by way of example
select * 
from Table
where
  start_date > '1621253095';

-- exactly one year ago, calculated dynamically
select * 
from Table 
where 
  start_date > 
    cast(unix_timestamp(date_add(now(), interval -1 year)) as varchar);

I'm not a MySQL guy really so forgive any syntax errors and fix up the sql as needed to work in MySQL.

Resources:

PostgreSQL: how to convert from Unix epoch to date?

https://www.postgresonline.com/article_pfriendly/3.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文