sql - Remove seconds from datetime -


i have query below:

select    lower(convert(varchar(10), getdate(), 101) +  ' '+   substring(convert(varchar(20), getdate(), 22),9,len(getdate()))) 

in query getting result as:

06/27/2014   6:23:57 pm 

i want remove seconds (i.e. 57) above.

my intentded result is:

06/27/2014   6:23 pm 

how can obtain it??

i tried adding length in query as:

select    lower(convert(varchar(10), getdate(), 101) +  ' '+   substring(convert(varchar(20), getdate(), 22),9,len(getdate())+1)) 

but didnt help.

plase me.

try below

 select cast(datepart(dd,getdate()) varchar)+'/' +cast(datepart(mm,getdate()) varchar) +'/'+cast(datepart(yyyy,getdate()) varchar) +' '+cast(datepart(hh,getdate()) varchar) +':'+cast(datepart(mi,getdate()) varchar) 

also @ custom date/time formatting in sql server


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -