PostgreSQL获取年月日,获取年份
select to_char(t.detect_date,‘YYYY’)select extract(year from now())为double precision 格式类型select to_char((SELECT now()::timestamp),‘yyyy’)select to_char((SELECT now()::timestamp+ ‘1 year’),‘yyyy’)selec
·
PostgreSQL获取年月日,获取年份
PostgreSQL获取年月日
1.获取当前日期的年份
select to_char(t.detect_date,‘YYYY’)
select extract(year from now())为double precision 格式类型
select to_char((SELECT now()::timestamp),‘yyyy’)
2.获取下一年
select to_char((SELECT now()::timestamp+ ‘1 year’),‘yyyy’)
3.获取上一年
select to_char((SELECT now()::timestamp+ ‘-1 year’),‘yyyy’)
其他都为为 character varying 格式类型
更多推荐
已为社区贡献15条内容
所有评论(0)