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
 SQL Server Development (2000)
 date switch

Author  Topic 

sardinka
Posting Yak Master

142 Posts

Posted - 2005-11-09 : 15:31:53
How do I replace month with day value and day value with month.
Example:
2005-02-09 00:00:00.000
replace with
2005-09-02 00:00:00.000

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2005-11-09 : 15:50:54
[code]
Declare @A datetime,
@B datetime

Set @A = '2/9/2005'

Select convert(datetime,convert(varchar,day(@A))+'/'+convert(varchar,month(@A))+'/'+convert(varchar,year(@A)))
[/code]

Corey

Co-worker on children "...when I have children, I'm going to beat them. Not because their bad, but becuase I think it would be fun ..."
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-11-09 : 17:05:42
Just to be clear...

Are you fixing a conversion error?
Or do you simply want to present (correct) dates as dd/mm/yyyy instead of mm/dd/yyyy?

Be One with the Optimizer
TG
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2005-11-09 : 17:11:31
quote:
Originally posted by sardinka

How do I replace month with day value and day value with month.
Example:
2005-02-09 00:00:00.000
replace with
2005-09-02 00:00:00.000

If you think you have a good reason for doing this at all, experience shows there is a 95% chance you are wrong. This is a data presentation issue and should almost never be handled by the database.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-10 : 00:17:24
Where do you want to show these converted dates?
If you use Front End application or Reports you can make use of Format function there to format the date

Madhivanan

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

- Advertisement -