资源描述:
《oracletochar函数详解》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、ORACLEto_char函数详解2007年07月04日星期三下午05:41Thefollowingarenumberexamplesfortheto_charfunction.to_char(1210.73,'9999.9')wouldreturn'1210.7'to_char(1210.73,'9,999.99')wouldreturn'1,210.73'to_char(1210.73,'$9,999.00')wouldreturn'$1,210.73'to_char(21,'000099')wouldreturn'000021'Thefollowingisalistofvalid
2、parameterswhentheto_charfunctionisusedtoconvertadatetoastring.Theseparameterscanbeusedinmanycombinations. ParameterExplanationYEARYear,spelledoutYYYY4-digityearYYYYYYLast3,2,or1digit(s)ofyear.IYYIYILast3,2,or1digit(s)ofISOyear.IYYY4-digityearbasedontheISOstandardQQuarterofyear(1,2,3,4;JAN-MAR=
3、1).MMMonth(01-12;JAN=01).MONAbbreviatednameofmonth.MONTHNameofmonth,paddedwithblankstolengthof9characters.RMRomannumeralmonth(I-XII;JAN=I).WWWeekofyear(1-53)whereweek1startsonthefirstdayoftheyearandcontinuestotheseventhdayoftheyear.WWeekofmonth(1-5)whereweek1startsonthefirstdayofthemonthandendso
4、ntheseventh.IWWeekofyear(1-52or1-53)basedontheISOstandard.DDayofweek(1-7).DAYNameofday.DDDayofmonth(1-31).DDDDayofyear(1-366).DYAbbreviatednameofday.JJulianday;thenumberofdayssinceJanuary1,4712BC.HHHourofday(1-12).HH12Hourofday(1-12).HH24Hourofday(0-23).MIMinute(0-59).SSSecond(0-59).SSSSSSeconds
5、pastmidnight(0-86399).FFFractionalseconds.Thefollowingaredateexamplesfortheto_charfunction.to_char(sysdate,'yyyy/mm/dd');wouldreturn'2003/07/09'to_char(sysdate,'MonthDD,YYYY');wouldreturn'July09,2003'to_char(sysdate,'FMMonthDD,YYYY');wouldreturn'July9,2003'to_char(sysdate,'MONDDth,YYYY');wouldre
6、turn'JUL09TH,2003'to_char(sysdate,'FMMONDDth,YYYY');wouldreturn'JUL9TH,2003'to_char(sysdate,'FMMonddth,YYYY');wouldreturn'Jul9th,2003'Youwillnoticethatinsomeexamples,theformat_maskparameterbeginswith"FM".Thismeansthatzerosandblanksaresuppressed.Thiscanbeseenintheexamplesbelow.to_char(sysdate,'FM
7、MonthDD,YYYY');wouldreturn'July9,2003'to_char(sysdate,'FMMONDDth,YYYY');wouldreturn'JUL9TH,2003'to_char(sysdate,'FMMonddth,YYYY');wouldreturn'Jul9th,2003'Thezeroshavebeensuppressedsothatthedaycomponentshowsas"9"asopposedto"0