資源描述:
《證券法律沖突研究法學(xué)理論論文》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在學(xué)術(shù)論文-天天文庫。
1、sql語句中日期時(shí)間格式化查詢(DateandtimeformattedqueryinSQLstatement)Editdelete
2、datetimeformatSQLstatementinthequerySnowtigerpublished:2007-12-1413:48Todayinsearchofmembermanagementsystem,Ifoundthatthesearchtimeisnotveryscientific,efficiencyisnottoohigh.Especiallywhensearchingthesametimespecifiedinthedata
3、base,Ihavesuchatimeformat"2007-5-2214:32:12"whenweareinthequerywhether2007-5-22anditsresultisequal.Notequal.Weallliketofindotherwaystosolvethisproblem.ButIfoundthatourmethodsweren'tverygood,becausewesometimeshadSQLSeverYoudon'tknowenoughaboutthesentencefeatures.SoIcheckedtheSQLServerhelp,andf
4、inallyfoundagoodthing,youcansolvethisproblemTheCONVERTfunctioncansolvethisproblembyformattingthetimelike2007-5-2214:32:12inthequeryorwhereclause:2007-5-22;Asfollows:IwillchecktheregistrationtimeoftheuserUserRegisterTimeSelect*from[user]whereUserActive=0andreplace(CONVERT(char(10),UserRegister
5、Time,111),='2007-05-22'orderby','-')UserRegisterTimedescInthiskeysentenceReplace(CONVERT(char(10),UserRegisterTime,111),'/','-');WhydoIwantreplacetochangethe"/"symbolinconvertto"-"?Becausetheformattingtimeofconverthereis:2007/05/22Onemorethingtonote:theformattingtimeofconvertisintheformof0bef
6、ore,suchas2007-1-112:12:31:2007-01-01,sobeforeyouquery,it'snecessarytoadd0tothenumberofmonthsanddayslessthan10(excluding10)inyourdate,Forexample:1shouldbe01Thespecificusageofthisnumberisasfollows:TransformationfunctionWhenMicrosoft?SQLServer?2000doesnotautomaticallyperformexpressiontransforma
7、tionsofdifferentdatatypes,conversionfunctionsCASTandCONVERTcanbeusedtoconvertthem.Thesetransformationfunctionscanalsobeusedtoobtainvariousspecialdataformats.Thesetwotransformationfunctionscanbeusedtoselectlists,Whereclauses,andanywherethatallowsexpressionstobeused.IfyouwanttheTransact-SQLprog
8、ramcodetocomplywiththeSQL-92standard,useCASTinsteadofusingCONVERT.IfyouwanttousethestylefunctioninCONVERT,useCONVERTinsteadofCAST.WhenusingCASTorCONVERT,twomessagesareneeded:Expressionstobeconverted(forexample,salesreportsrequiresalesdatatobe