Any SQL Server T-SQL Experts?

Matt Shields matt-urrlRJtNKRMsHrnhXWJB8w at public.gmane.org
Fri Feb 11 14:15:01 EST 2011


I know this is a long shot, but are there any T-SQL experts on the list?  I
need a query that will give me date/time in the format like this

YYYYMMDDHHmm (year, month, day, hour, minute) all with prepended zero's if
necessary.  So if the month is 02, it should appear as 02 not 2.

For example: 201002111411

The closest I've been able to come is the following, but it also gives me
seconds which I don't want.

SELECT replace(convert(varchar, getdate(),111),‘/’,”) +

replace(convert(varchar, getdate(),108),‘:’,”)

Also, if there's a better way than using replace, I'm good with that too.

-matt




More information about the Discuss mailing list