what's the best way to concatenate this date?

Hi.  I'm looking to get a datetime concatenated value from my table -- this is probably quite easy, but I'm not getting what I want.

this gives me this:  20050320
select convert(varchar(12),getdate(), 112)

what's the right way to return this:  20050320.14:23:53.140

LVL 1
RLLewisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Racim BOUDJAKDJIDatabase Architect - Dba - Data ScientistCommented:
This should get you closer to your purpose...
select (convert(varchar(12),getdate(), 112) + '.' + right (cast(getdate() as varchar(50)), len(cast(getdate() as varchar(50)) - 11)  
0
RLLewisAuthor Commented:
nope - syntactically incorrect.  i added the missing paren after the first getdate(), 112), but now I'm getting this error:
Syntax error converting the varchar value 'Mar 20 2005  2:49PM' to a column of data type int.

select (convert(varchar(12),getdate(), 112)) + '.' + right (cast(getdate() as varchar(50)), len(cast(getdate() as varchar(50)) - 11))

this gets me this:  20050320. 2:48PM
select (convert(varchar(12),getdate(), 112)) + '.' + RIGHT(CONVERT(VARCHAR(30), getdate(), 100), 7)

but I don't want the time in that format.  any ideas?
0
BillAn1Commented:
try this one :

select replace(replace(convert(varchar(23), getdate(), 121),'-',''),' ','.')
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RLLewisAuthor Commented:
perfect.  thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.