sql 日期分离
来源:百度知道 编辑:UC知道 时间:2024/05/28 16:27:56
date
2009-01-02
2008-12-14
要查询完得到
year
2009
2008
2009-01-02
2008-12-14
要查询完得到
year
2009
2008
select year(date) as year from table
--SqlServer用法
Select to_number(to_char(date,'yyyy')) From table
SELECT EXTRACT(YEAR FROM Date) FROM Table
--Oracle用法
以上返回的year都为数值型
以上希望对你有所帮助
select yeaar(date) as 年份 from table
SELECT DATEPART (YEAR, DATE) FROM 表名;
so easy:
select extract (year from date ) year from table;
select convert(varchar(4),[date],120) from [你的表]
left('2009-01-02',4)