Any SQL Server T-SQL Experts?

Raenac raenac-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Fri Feb 11 14:37:03 EST 2011


select convert(varchar,getdate(),112)+replace(convert(varchar,
getdate(),108),':','')

gives you YYYYMMDDHHmmss

tried that?

On Fri, Feb 11, 2011 at 2:15 PM, Matt Shields <matt-urrlRJtNKRMsHrnhXWJB8w at public.gmane.org> wrote:

> 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
> _______________________________________________
> Discuss mailing list
> Discuss-mNDKBlG2WHs at public.gmane.org
> http://lists.blu.org/mailman/listinfo/discuss
>




More information about the Discuss mailing list