Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Any SQL Server T-SQL Experts?



On Fri, Feb 11, 2011 at 2:37 PM, Raenac <raenac-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:

> 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
>>
>
>
Yup, figured out changing the first line to use 112 and I can do away with
the first replace.  Still need a way to not have seconds in there.

-matt





BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org