Questions tagged [datetime2]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
-2
votes
1answer
55 views

Operand type clash: int is incompatible with datetime2

Having issues with the code below. ERROR: Msg 206, Level 16, State 2, Procedure usp_TRAC_PSE_Step_12_Resource_Request_OBJECT-Production-Part1, Line 93 Operand type clash: int is incompatible with ...
0
votes
1answer
217 views

The datediff function resulted in an overflow. But should not

I have this stored procedure in SQL-Server 2014 USE [provbank] GO /****** Object: StoredProcedure [dbo].[GetHBSeconds] Script Date: 2018-10-05 08:40:07 ******/ SET ANSI_NULLS ON GO SET ...
3
votes
1answer
205 views

What does 0 in DATEDIFF(MINUTE, 0, <Date>) actually mean?

So, our data team asked for some help in solving a problem they had. I eventually tracked it down to some really out of range data (1/1/0001) and a DATEDIFF function they were using. While I've ...
3
votes
1answer
105 views

SQL Server 2016 Compatibility Level and Datetime 2

We have been running SQL Server 2016 for some time now but initially left the database compatibility level to SQL Server 2008 (100). Recently we did update the DB Compatibility Level to 2016 (130) but ...
3
votes
2answers
2k views

Calculate total hours per day based on “TIME_IN” data in one row and “TIME_OUT” data on the next row

I need to calculate the actual time spent in the office per day. I have seen several examples online, but they all have TIME_IN and TIME_OUT in the same row. My application puts entries into a new ...
2
votes
2answers
414 views

12 fraction digits in SQL Server

We are currently migrating from DB2 to SQL Server. DB2 supports TIMESTAMP(6-12) while DATETIME2 only supports up to 7 decimals. Since we have many keys represented as TIMESTAMP(12) what would be the ...
4
votes
2answers
984 views

Datetime2 rounding issue

We are working on a multi-database application (read and write to multiple databases). The datamodel is identical on the databases. We are inserting a timestamp (12 fraction digits) value in a ...
0
votes
1answer
954 views

How to set datetime2 to mandate?

I want to create a SQL Script to clean datetime2 field and set it up to datetime2 begin '1-1-0001 12:00:00'. How to set GETDATE() to '1-1-0001 12:00:00' instead of using convert function ? UPDATE ...
13
votes
1answer
9k views

SQL dateTime2(0) vs dateTime2(2)

According to this article https://msdn.microsoft.com/en-us/library/bb677335.aspx. Storage size 6 bytes for precisions less than 3; 7 bytes for precisions 3 and 4. All other precisions require 8 ...
2
votes
1answer
4k views

Help with out-of-range value

I have this query that is giving me an error The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. Query: select COUNT(*) from dbo.patient ...
48
votes
7answers
49k views

How to combine date and time to datetime2 in SQL Server?

Given the following components DECLARE @D DATE = '2013-10-13' DECLARE @T TIME(7) = '23:59:59.9999999' What is the best way of combining them to produce a DATETIME2(7) result with value '2013-10-13 ...