SAPHANA学习(25):SQL Function(Y)

/*

154.YEAR(<date>)

返回年

 

YEARS_BETWEEN(<date_1>, <date_2>)

返回两个日期之间年份

*/

SELECT YEAR (TO_DATE ('2011-05-30', 'YYYY-MM-DD')) FROM DUMMY;

--返回2
SELECT YEARS_BETWEEN(TO_DATE('2001-01-01'), TO_DATE('2003-03-14')) FROM DUMMY;

--返回0,不满1年
SELECT YEARS_BETWEEN(TO_DATE('2004-01-01'), TO_DATE('2003-03-14')) FROM DUMMY;

--返回-1
SELECT YEARS_BETWEEN(TO_DATE('2004-03-14'), TO_DATE('2003-03-14')) FROM DUMMY;

 

posted @ 2020-11-07 09:00  渔歌晚唱  阅读(136)  评论(0编辑  收藏  举报