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)
 getdate()

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-10-26 : 08:42:07
Hi,
I would like to get the date and time but without the millisecond.
i.e.
select getdate()
but this returns milliseconds which I do not want.
Thanks

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-10-26 : 08:44:16
How about
select convert(char(20), getdate(), 113)
?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-26 : 08:51:36
quote:
Originally posted by arkiboys

How about
select convert(char(20), getdate(), 113)
?


That would become varchar. You need to convert it back to datetime

select cast(convert(char(20), getdate(), 113) as datetime)

Madhivanan

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

NeilG
Aged Yak Warrior

530 Posts

Posted - 2007-10-26 : 08:56:45
Does
Cast (detdate() as smalldatetime)

Not also work
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-26 : 09:00:29
quote:
Originally posted by NeilG

Does
Cast (detdate() as smalldatetime)

Not also work


That will omit seconds as well

Madhivanan

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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-26 : 09:06:57
Without datatype convertion use this

select dateadd(ms,-(datepart(ms,getdate())),getdate())

Madhivanan

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

- Advertisement -