开发者

how to display date and time seperatly in sqlserver

开发者 https://www.devze.com 2023-02-18 19:18 出处:网络
DATENAME(MM,TripDateTime) + \' \' + CAST(DAY(TripDateTime) AS VARCHAR(2)) + \', \' + RIGHT(CAST(YEAR(TripDateTime) AS VARCHAR(4)), 4) as TripDate
DATENAME(MM,TripDateTime) + ' ' + CAST(DAY(TripDateTime) AS VARCHAR(2)) + 
 ', ' + RIGHT(CAST(YEAR(TripDateTime) AS VARCHAR(4)), 4) as TripDate

note:: tri开发者_如何学JAVApdateTime is combination of date and time here i will get the Date as march 31, 2011

but as simultaneously i want to get time(hours,minuts,sec) how can i get?? can u help me?


You can use convert to convert a date time value in anyway you like:

read docu here : http://msdn.microsoft.com/en-us/library/aa226054(v=sql.80).aspx


Add

   ,CONVERT(VARCHAR(8), TripDateTime, 108) AS TripTime

to your query (Assuming that you want it as a separate column).

0

精彩评论

暂无评论...
验证码 换一张
取 消