Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop milliseconds from datetime datatypes 1

Status
Not open for further replies.

DiggerDog

Programmer
Nov 24, 2002
60
AU
Hi

I need to compare two datetime fields but wish to drop the datetime component of the datatype - is this possible

E.g I want
2004-03-24 16:14:23.400 to =

2004-03-24 6:14:23.67

 
you can use a convert function with a style of 120

"Shoot Me! Shoot Me NOW!!!"
- Daffy Duck
 
Hi MDXer

I tried using convert with a style of 120 before but it still returned the millisecond part

See code below

Declare @Date datetime
select @Date = getdate()

select @Date
-- returned 2004-03-25 11:34:11.670

select @Date = Convert(datetime, @date, 120)
select @Date

-- returned 2004-03-25 11:34:11.670


 
convert to a varchar

Code:
select @Date = Convert(varchar, @date, 120)
[code]

"Shoot Me! Shoot Me NOW!!!"
                           - Daffy Duck
 
Hi MDXer

That works perfectly - Thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top