select convert(varchar(16), getdate(), 101)+LEFT(REPLACE(convert(varchar, getdate(), 108), '

selectconvert(varchar(16),getdate(), 101)+LEFT(REPLACE(convert(varchar,getdate(), 108),':',''),4)

From above query I get

mmddyyyyhhmm

but it' s yyyy and hour can not be separated

04/12/200702:05

How can I separated the year and hour ?

Thanks

Daniel

[1187 byte] By [danielku] at [2008-1-10]
# 1
You almost have it.

Just concatenate your separator between the date parts you're constructing.

Like

select convert(varchar(24), getdate(), 101) + ' ' + LEFT(REPLACE(convert(varchar, getdate(), 108), ':', ''),4)

DaleJ at 2007-10-3 > top of Msdn Tech,SQL Server,Transact-SQL...
# 2

Try:

select convert(varchar(10), getdate(), 101) + ' ' + REPLACE(convert(varchar(5), getdate(), 108), ':', '')

AMB

hunchback at 2007-10-3 > top of Msdn Tech,SQL Server,Transact-SQL...

SQL Server

Site Classified