I am using this query to display date and time. I have used the 113 in conversion function that gave me the date format with spaces and i replaced it with a /, now i just want to take out the / that separates date from time.
SELECT [ID]
,REPLACE(convert(varchar, ReceivedMessages.ReceivedDateTime, 113), ' ','/') as RecievingDate
FROM [CmsSMSDb].[dbo].[ReceivedMessages]
where Convert(date,ReceivedDateTime)>= @DateFrom AND Convert(date,ReceivedDateTime)<= @DateTo
It gives this result:
09/Jun/2014/10:04:07:000
That's what i want, it works perfectly but problem is that i want to remove '/' after 2014, like 09/Jun/2014 10:04:07:000
but in other places '/' this should remain same but it should not appear after 2014.
how ?
If you are using SQLServer 2012 or better you can use the new function
FORMAT
In the
FORMAT
functionhh
is for 12-hour format,HH
for 24-hour format, you can addtt
to getAM
orPM
, to see the difference tryAlso you should not change the data stored (that can be in a index) to match a parameter, if should be the other way around