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 manipulation

Author  Topic 

mk_garg20
Constraint Violating Yak Guru

343 Posts

Posted - 2005-09-07 : 21:48:53
Hi

Can i write following conversion in a better way?

select Convert(datetime,Convert(varchar,GETDATE(),103),103)+1

Thanks

mk_garg

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-09-07 : 21:50:44
SELECT DateAdd(day, DateDiff(day, 0, getdate())+1, 0)

Don't know if it's better, but it avoids having to convert it to varchar and back.
Go to Top of Page

mk_garg20
Constraint Violating Yak Guru

343 Posts

Posted - 2005-09-07 : 22:29:34
Thanks

mk_garg
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-09-07 : 22:30:41
I have no doubt it's better. That double conversion can be pretty costly.

you could slightly simplify it (although this might be a little less readable)
SELECT DateAdd(day, DateDiff(day, 0, getdate()), 1)

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -