postgresql age

postgresql age
计算出指定时间点到当前时间的时间差

# select extract(year from age('2013-01-01'::date));
 date_part 
-----------
         6

结果是一串人类可读的文字,现在需要截取其中自己需要的部分

# select extract(year from age('2019-01-01'::date));
 date_part 
-----------
         0

https://www.postgresql.org/docs/10/functions-datetime.html

发布了236 篇原创文章 · 获赞 145 · 访问量 44万+

猜你喜欢

转载自blog.csdn.net/u011944141/article/details/91453069