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).
精彩评论