资源描述:
《oracle中tochar的用法》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、Thefollowingarenumberexamplesfortheto_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' Thefollowingisalistofvalidparameterswhenthet
2、o_charfunctionisusedtoconvertadatetoastring.Theseparameterscanbeusedinmanycombinations. ParameterExplanation YEARYear,spelledout YYYY4-digityear YYY YY YLast3,2,or1digit(s)ofyear. IYY IY ILast3,2,or1digit(s)ofISOyear. IYYY4-digityearbasedontheISOstandard QQuarterofyear(1,2,3
3、,4;JAN-MAR=1). MMMonth(01-12;JAN=01). MONAbbreviatednameofmonth. MONTHNameofmonth,paddedwithblankstolengthof9characters. RMRomannumeralmonth(I-XII;JAN=I). WWWeekofyear(1-53)whereweek1startsonthefirstdayoftheyearandcontinuestotheseventhdayoftheyear. WWeekofmonth(1-5)whereweek1star
4、tsonthefirstdayofthemonthandendsontheseventh. 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).
5、 HH24Hourofday(0-23). MIMinute(0-59). SSSecond(0-59). SSSSSSecondspastmidnight(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
6、(sysdate,'FMMonthDD,YYYY');wouldreturn'July9,2003' to_char(sysdate,'MONDDth,YYYY');wouldreturn'JUL09TH,2003' to_char(sysdate,'FMMONDDth,YYYY');wouldreturn'JUL9TH,2003' to_char(sysdate,'FMMonddth,YYYY');wouldreturn'Jul9th,2003' Youwillnoticethatinsomeexamples,theformat_maskparameter
7、beginswith"FM".Thismeansthatzerosandblanksaresuppressed.Thiscanbeseenintheexamplesbelow. to_char(sysdate,'FMMonthDD,YYYY');wouldreturn'July9,2003' to_char(sysdate,'FMMONDDth,YYYY');wouldreturn'JUL9TH,2003' to_char(sysdate,'FMMonddth,YYYY');wouldreturn'Jul9th,2003' Thezeroshavebee