新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
大數(shù)據(jù)開發(fā)中文年齡函數(shù)的示例代碼-創(chuàng)新互聯(lián)
這篇文章主要介紹大數(shù)據(jù)開發(fā)中文年齡函數(shù)的示例代碼,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
create or replace function CHINESEAGE(BirthDate in date, NowDate in date) return string is Result string(80); -- 返回值 MonthCount number(4,0); -- 出生的月份 DayCount number(6,0); -- 去除月份后的余數(shù)(天) begin -- 如果生日大于當(dāng)前日期,則提示錯誤 if BirthDate > NowDate or BirthDate is null or NowDate is null Then Result := '不詳'; return(Result); end if; -- 獲取出生多少個月余多少天 SELECT trunc(Mon), trunc((Mon - trunc(Mon)) * 31) INTO MonthCount,DayCount FROM (SELECT months_between(NowDate, BirthDate) Mon FROM dual) V; -- 如果出生60個月以上,年齡顯示為 ##歲 if MonthCount >= 60 then Result := to_char(trunc(MonthCount/12))||'歲'; -- 如果出生12-59個月,年齡顯示為 ##歲##月 elsif MonthCount >= 12 then Result := to_char(trunc(MonthCount/12))||'歲'||to_char(mod(MonthCount,12))||'月'; -- 如果出生1-11個月,年齡顯示為 ##月##天 elsif MonthCount >= 1 then Result := to_char(MonthCount)||'月'; if DayCount >= 1 then Result := Result || to_char(DayCount) || '天'; end if; -- 如果出生1天-1個月,年齡顯示為##天 elsif DayCount >= 1 then Result := to_char(DayCount)||'天'; -- 如果出生不足1天,年齡顯示為1天 else Result := '1天'; end if; return(Result); end;
以上是“大數(shù)據(jù)開發(fā)中文年齡函數(shù)的示例代碼”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道!
本文標(biāo)題:大數(shù)據(jù)開發(fā)中文年齡函數(shù)的示例代碼-創(chuàng)新互聯(lián)
本文URL:http://www.dlmjj.cn/article/gjigd.html