Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove milliseconds from time datatype and also: is there a millisecond-less time datatype?

I have seen posts in the question on how to remove milliseconds from the datetime datatype in MS SQL.

But what about the time datatype - what is the easiest way to remove milliseconds from the time datatype?

Also: Is there any time datatype in MS SQL (2008) that doesn't include milliseconds?

Thanks all!

like image 451
DotNetDeveloper Avatar asked Mar 07 '13 06:03

DotNetDeveloper


People also ask

How do I remove milliseconds from a timestamp?

Use the setSeconds() method to remove the seconds and milliseconds from a date, e.g. date. setSeconds(0, 0) . The setSeconds method takes the seconds and milliseconds as parameters and sets the provided values on the date. Copied!


1 Answers

One of the easiest way to remove milliseconds is:

SELECT CONVERT(VARCHAR, GETDATE(), 20) 

And if you dont want to include milliseconds:

TIME(0) will help

Example

CAST(DATEADD(second, SUM(hora), '00:00:00') AS time(0))
like image 88
Praveen Nambiar Avatar answered Sep 30 '22 18:09

Praveen Nambiar