Home > Database > Mysql Tutorial > get year from a postgresql DATE

get year from a postgresql DATE

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 14:58:30
Original
1298 people have browsed it

get year from a postgresql DATE 1、如果所在的列属性 mydate 本身为 DATE 类型,则使用: [sql] SELECT EXTRACT(year FROM mydate) FROM mytable; 2、如果所在的列属性 mydate 为 varchar 类型,则先使用 to_date()将其转换为 DATE类型,然后在使用 EXTRAC

get year from a postgresql DATE

 

1、如果所在的列属性 mydate 本身为 DATE 类型,则使用:

 

[sql] 

SELECT EXTRACT(year FROM mydate) FROM mytable;  

 

2、如果所在的列属性 mydate 为 varchar 类型,则先使用

 

 to_date()将其转换为 DATE类型,然后在使用 EXTRACT year:

 

[sql] 

SELECT EXTRACT(year FROM to_date(mydate, )) FROM mytable;  

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template