Questions tagged [datetime2]

A SQL Server type that defines a date that is combined with a time of day that is based on 24-hour clock. datetime2 can be considered as an extension of the existing datetime type that has a larger date range, a larger default fractional precision, and optional user-specified precision.

A SQL Server data type that define a date that is combined with a time of day that is based on a 24-hour clock. datetime2 can be considered as an extension of the existing datetime type that has a larger date range, a larger default fractional precision, and optional user-specified precision.

References and resources

155 questions
3
votes
0 answers

Django: 'unicode' object has no attribute 'tzinfo'. Production server only

I'm stumped. With my local set up (python manage.py runserver) everything runs fine. With my production set up (wsgiserver.CherryPyWSGIServer), I get 'unicode' object has no attribute 'tzinfo' when my program tries to convert datetime2(7) from the…
BottleZero
  • 893
  • 6
  • 13
3
votes
3 answers

Force DateTime with Entity Framework Database First

I am connecting to a database using EF database first. Therefore my models are autogenerated. When I update a record my DateTimes are getting written as SQL type DateTime2. The production server is SQL Server 2005 (no comments please), so the…
3
votes
2 answers

How to migrate datetime to datetime2 with new SQL Server Native Client

We are currently migrating our database from datetimeto datetime2 including SQL Server Native Client v11 (SQL Server 2012). The database update was easily done, but the problems come along with the new SQL Server Native Client 11 we want to use. In…
Danielku15
  • 1,490
  • 1
  • 13
  • 29
3
votes
2 answers

Insert date string to datetime2 in TSQL insert

I need to insert a date string as DATETIME2 in the QUEUE table in Microsoft Sql Server. DB structure: CREATE TABLE "QUEUE" ( ID INT PRIMARY KEY NOT NULL, TEAMID VARCHAR(550) , STATUS VARCHAR(50) , MSG VARCHAR(50) , TIME …
Vijax
  • 65
  • 1
  • 1
  • 5
3
votes
1 answer

Searching for a date In a partitioned table in SQL Server

When doing queries on a partitioned table in SQL Server, does one have to do anything special? The reason I am asking is because we have a fairly large SQL Server table that is partitioned on a `datetime2(2)' column by day. Each day is mapped to…
Zapnologica
  • 22,170
  • 44
  • 158
  • 253
3
votes
1 answer

How to insert DateTime (or DateTime2) with Dapper?

I'm trying to do the following: var p = new DynamicParameters(); p.Add(...); p.Add(...); // ideally I want to insert null for end date, but I also tried DateTime.MinValue // or some other date, but doesn't help p.Add("@endDate", null,…
Shankar
  • 1,634
  • 1
  • 18
  • 23
2
votes
3 answers

Does SQL Server 2005 support datetime2

I can't find in the official documentation if SQL Server 2005 supports the datetime2 data type.
ahmd0
  • 16,633
  • 33
  • 137
  • 233
2
votes
1 answer

SQL Server 2008 stored procedure with DateTime2

I have a small question about stored procedures and the DateTime2 datatype in SQL Server 2008. I got several stored procedures using the DateTime2 datatype and I want to insert the date 0001.01.01 00:00:00 but this won't work with VB.net and I…
Lim
  • 135
  • 1
  • 2
  • 8
2
votes
0 answers

mssql-jdbc datetime java type is converted to datetime2 in compatible SQLServer 2014 vs SQLServer2016

We are using SQLServer 2012-2016. DATETIME data type is part of the key in many tables. when we execute query with jdbcTemplate.query(query, queryParams, resultSetExtractor) What is send to SQLServer is : sp_executesql N'SELECT * FROM…
2
votes
3 answers

Convert varchar "dd/mm/yyyy hh:mm:ss" to datetime2

I have a column of dates in varchar(50) format written as "dd/mm/yyyy" I need to convert it to datetime2 format however when it runs it assumes that the format is "mm/dd/yyyy" and converts accordingly, throwing an error when the day field exceeds…
Kron
  • 473
  • 5
  • 20
2
votes
2 answers

How to compare dates with different precision

I asked this question regarding how to compare datetime2 values, but ignoring the nanoseconds. Since there is some rounding involved, it fails to compare the values properly. In java, I can get a Long-value from Date and Timestamp which represents…
XtremeBaumer
  • 6,275
  • 3
  • 19
  • 65
2
votes
0 answers

Entity Framework Migration to datetime2

We use Entity Framework 6 code first. We recently decided to move datetime format in the database to datetime2 format. Our database currently contains lot of data and about 262 tables. By googling it, I found this answer which describs how to…
Jacob
  • 3,598
  • 4
  • 35
  • 56
2
votes
1 answer

SQL TRY_CONVERT DateTime vs DateTime2

I have a situation where I need to convert datetime string values in a column to a more standardised format, the converting process is quiet manual I am not just casting and storing. So the script grabs the value, fumbles it around and stores it…
Heinrich
  • 2,144
  • 3
  • 23
  • 39
2
votes
1 answer

Loss of precision when mapping datatable columns to datetime2 fields

Background The field TimestampCreation is created as such in the DB: [TimestampCreation] [datetime2](7) NOT NULL If I add the field to a datatable like this: table.Columns.Add(new DataColumn("TimestampCreation", typeof(DateTime))); the value loses…
Spikee
  • 3,967
  • 7
  • 35
  • 68
2
votes
1 answer

Unexpected error about DateTime type

I have a .aspx page for adding new product include the following field: ID, Name, DateTime, Price and it run well at localhost but when I publish it and up to the server, then I get the following error: System.Data.UpdateException: An error…
ByulTaeng
  • 1,269
  • 1
  • 21
  • 40
1 2
3
10 11