Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 date format

Author  Topic 

ratcho
Starting Member

18 Posts

Posted - 2002-08-28 : 16:52:40
Please help me with the following problem:

getdate() gives me this:
Aug 28 2002 4:49PM

Now, I need the date in the following format:

20020828164959

(including seconds)

I have already tried
convert(char, getdate(), 112)
but the result doesn't include the hours, minutes and seconds

Thanks a lot for your time

joshb
Yak Posting Veteran

52 Posts

Posted - 2002-08-28 : 17:03:05
I'm sure there are many different ways to do this, here's one:

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

Go to Top of Page

ratcho
Starting Member

18 Posts

Posted - 2002-08-28 : 17:14:24
Thanks a lot, it's perfect

Go to Top of Page
   

- Advertisement -