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
2
votes
1 answer

EF6 datetime2 conversion to datetime resulted in an out-of-range value

I've just deployed server code that used to work literally a week ago. The part of the code that results in the error did not change, however the object itself did. It is a Model First approach (converted from Database First), and I've added two…
fonix232
  • 2,132
  • 6
  • 39
  • 69
2
votes
1 answer

Convert a string to datetime2

Iam using an application that gets data through a communication protocol , and among data i get is dates and i managed to form a string date out of that in this form : "dd/MM/yyyy HH:mm:ss.mmm" I want to insert it in the database :…
Ahmed Aekbj
  • 91
  • 1
  • 12
2
votes
1 answer

JPA creating column LocalDateTime as datetime2 in SQLServer 2008

My entity has this attribute... @Convert(converter = LocalDateTimeAtributeConverter.class) @Column(name="dthr_ult_atualizacao") private LocalDateTime ultimaAtualizacao; In the server, the column is created by the JPA as: dthr_ult_atualizacao …
2
votes
3 answers

Issue with converting a date using Carbon

$value="Mar 10 2016 09:12:03:000AM"; return Carbon::createFromFormat('Y-m-d H:i:s.u0', $value); Please will someone please tell me how to use Carbon to convert this date to that format. I'm getting: InvalidArgumentException in Carbon.php line…
JoeAny
  • 23
  • 1
  • 4
2
votes
1 answer

How can one bind datetime2(SQL_C_TYPE_TIMESTAMP) using SQLBindParameter?

I am trying to bind datetime2 parameter using SQLBindParameter for SQL_TYPE_TIMESTAMP data type as below SQLBindParameter(hStmt, 7, SQL_PARAM_INPUT, SQL_C_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP, 0, 0, &datetime2, 0, NULL); also tried this: rc =…
Genjutsu
  • 223
  • 2
  • 12
2
votes
2 answers

How to force LINQ to SQL to pass .NET DateTime as datetime2?

I have a simple query in LINQ to SQL: var id = 23479824; var date = Changes.Where(ch => ch.Id == id).First().Date; var diff = Changes.Where(ch => ch.Id == id).Select(ch => SqlMethods.DateDiffNanosecond(date, ch.Date)).First(); The diff variable…
TN.
  • 18,874
  • 30
  • 99
  • 157
2
votes
1 answer

Using Time(0) and Datetime2(0) in SQL Server

I'm using SQL Server 2008 R2. Using SQL Server Management Studio, I've created a database, and a new table. In the table I have 2 columns with data types Time(0) and Datetime2(0). I've inserted a record in this table with values…
alex
  • 694
  • 3
  • 15
  • 35
2
votes
3 answers

Hibernate MSSQL datetime2 mapping

I have a stored procedure which is returning a column having datatype as datetime2 in database and Date in Java file. When I am trying to call getTime() on that obtained time from database. It's returning 19994321211 millisecond which is equivalent…
jasminum
  • 471
  • 1
  • 7
  • 12
2
votes
2 answers

Sql Server Datetime2: Eliminate the seconds part in datetime2

How can I eliminate the seconds part in my query. I have used DateADD to show the seconds part as 0 but I just want to ignore it. I only want to show the date hours: minutes I have used this query and it returns me something like this SELECT…
Nosheen Javed
  • 175
  • 1
  • 5
  • 21
2
votes
1 answer

Why does the datetime type in SQL Server Compact round values?

I've run across something that surprised me. I am using WinPcap to collect data off a network. Internally, WinPcap uses the Windows performance counters to generate its timestamps. I know they are subject to drift, but these timestamps…
Matt Davis
  • 45,297
  • 16
  • 93
  • 124
2
votes
3 answers

SQL Server Query on todays date using datetime2

I have a SQL Server database that when I open it on screen I want it to just show the records that have been added today. I have the date stored in a field called DateAdded and it is of DateTime2 data type. I tried this string dateAdded =…
saintsfanuk
  • 332
  • 1
  • 5
  • 19
2
votes
2 answers

Allow Entity Framework 4.5 to use datetime2 with SQL Server CE4

I am working on an Entity Framework project using SQL Server 2008. We recently changed to use the datetime2 field type for a lot of our Dates as we need the precision. This works fine against our live and development databases, but as part of our…
glenatron
  • 11,018
  • 13
  • 64
  • 112
2
votes
1 answer

Making a datetime2 from three fields in Ms SQL Server 2008

I am stock whit a huge table containg more than 13,8k of rows. Its layout is something like, CREATE TABLE table1( [id] [int] NOT NULL, [regnr] [char](10) NULL, [kilde] [char](100) NULL, [dd] [char](10) NULL, [mm] [char](10) NULL, [yyyy] [char](16)…
1
vote
2 answers

How is SQL Server's timestamp2 supposed to work in JDBC?

I'm having some trouble trying to use timestamp2 instead of Timestamp in SQL Server 2008. Apparently, rs.getTimestamp has very different behavior between timestamp and timestamp2. However, I can't find any documentation stating that there should…
Pixel
  • 374
  • 5
  • 15
1
vote
1 answer

EF: Change ProviderManifestToken or change datatype?

Two questions, followed by details: What other side effects occur when I change my ProviderManifestToken to "2005"? Is it unwise to make the schema change in the database from datetime to datetime2? For instance, if I leave my ProviderManifestToken…
lance
  • 16,092
  • 19
  • 77
  • 136