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 2005 Forums
 Transact-SQL (2005)
 Date Format

Author  Topic 

adamsm28
Starting Member

5 Posts

Posted - 2007-12-03 : 08:02:00
Hi, I need to convert getdate() to the following format:

mmhhddmmyyyy

Could one of you gurus please advise?

Many thanks!
Mark A

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-03 : 08:10:41
quote:
Originally posted by adamsm28

Hi, I need to convert getdate() to the following format:

mmhhddmmyyyy

Could one of you gurus please advise?

Many thanks!
Mark A


Where do you want to show the converted dates?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

adamsm28
Starting Member

5 Posts

Posted - 2007-12-03 : 08:12:38
I need to pass it to a var so that I can pass the datetime stamp to a file name e.g. "mmhhddmmyyyy<somestring>.dat"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-03 : 08:33:46
[code]
select substring(convert(varchar(10), getdate(),108),4,2)+
substring(convert(varchar(10), getdate(),108),1,2)+
replace(convert(varchar(10), getdate(),103),'/','')[/code]

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

adamsm28
Starting Member

5 Posts

Posted - 2007-12-03 : 08:38:37
Wow - you are the man!

thanks! Saved me hours of sweat.

BR
Mark
Go to Top of Page
   

- Advertisement -