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
0
votes
2 answers

datetime2 overflow error

I'm trying to add 13 years to a birthdate that's stored as datetime2 using the following syntax and (dateadd(yy,13,isNull(cast(p.birthDTS as datetime),cast('1/1/1950' as datetime)))>=@svcStart) and I get the Adding a value to a 'datetime' column…
0
votes
1 answer

Insert datetime2 into database

I am using datetime2 as the datatype for checkIn and checkOut. Previously I can add into database with this code. //value for checkIn = 12/25/2015 2:00:00 PM checkIn = DateTime.ParseExact(Session["checkInDate"].ToString(), "dd/MM/yyyy",…
Xion
  • 452
  • 2
  • 6
  • 25
0
votes
1 answer

EF6 Code First: Fixing DateTime2

I have a code first EF6 database which contains a number of DateTime fields. These were mapped to datetime fields in the localdb database when the tables were created. I recently introduced some time zone adjustments to the values stored in some of…
Mark Olbert
  • 6,584
  • 9
  • 35
  • 69
0
votes
0 answers

C# DateTime.Now different results in database

I have a SQL Server 2008 table with to different dates: OrderDate and DeliveryDate. I'm using Entity Framework 6. Both fields are datetime2(0) type. Here is how I'm creating my object before saving it to database: DateTime now =…
Daniel Kern
  • 41
  • 1
  • 4
0
votes
1 answer

DTS cannot convert datetime2 to datetime

I need to make a DTS package to convert data from one database to another. The structures are essentially the same except that all datetime2 fields have been changed to datetime. When attempting to run the DTS package against the database, it…
Dirk Dastardly
  • 1,017
  • 2
  • 12
  • 23
0
votes
1 answer

SQL Server datetime2 and ODBC

According to the MSDN documentation datetime2 has a range from 0001-01-01 to 9999-12-31. It also says that the ODBC string literal looks as follows: { ts 'yyyy-mm-dd hh:mm:ss[.fractional seconds]' } Why do the last three statements fail? They only…
Antineutrino
  • 1,093
  • 3
  • 10
  • 26
0
votes
1 answer

Update timestamp in datetime2

We have a software designed to run on MS SQL 2005, we have upgraded the database to 2008 R2, and are trying to increase accuracy in our timestamp by using Datetime2 instead of Datetime. The software running is still unchanged, and will have the…
0
votes
0 answers

LINQ2SQL Weirdness With DateTime2

My application logs messages to a database fairly frequently, and so the table uses the DateTime2 type for greater precision. I'm inserting entries using LINQ2SQL, with the 'Server Data Type' property on the .dbml set to 'DATETIME2 NOT NULL'.…
trilson86
  • 939
  • 1
  • 9
  • 20
0
votes
2 answers

Need output in dd/MM/yyyy format from table value pair

Here is my code for passing table value pair to stored procedure. DOJ field is DateTime and in SP, DOJ field is date. Both are compatible. Output is like dd/MM/yyyy. If DOJ field is DateTime and in SP, DOJ field is DateTime2(3), o/p is dd/MM/yyyy…
0
votes
1 answer

Adding a Primary Key and Altering a Column to DatetTime2

I have a table that tracks statuses that a particular file goes through as it is checked over by our system. It looks like this: FileID int Status tinyint TouchedBy varchar(50) TouchedWhen datetime There is currently NO primary key on this table…
0
votes
1 answer

updating DATETIME causes sqlite error on BB10

I created my table with this query CREATE TABLE SETTINGS(NAME VARCHAR(1050), VALUE VARCHAR(1550),CREATE_DATE_TIME DATETIME,UPDATE_DATE_TIME DATETIME, PRIMARY KEY(NAME)) Then I inserted data like this INSERT INTO SETTINGS(NAME, VALUE…
Tahlil
  • 2,680
  • 6
  • 43
  • 84
0
votes
1 answer

Convert DateTime2 to DateTime from Stored Procedure Executed Result

How can i Convert DateTime2 to DateTime from Stored Procedure Executed Result ? I have a procedure which will execute a dynamically formed sql statement which will have an output of various columns in which there are some datetime2 data types. How…
msbyuva
  • 3,467
  • 13
  • 63
  • 87
0
votes
0 answers

opendatasource and datetime2

I'm using this trick to load Access data into a temporary table without having to specify all the columns (SQL Server 2008). SELECT * INTO #tempTable FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0', 'Data…
batkuip
  • 1,480
  • 3
  • 15
  • 25
0
votes
0 answers

DateTime error when updating rows using EF

I have a method that gets an existing row from a table in my database and updates some values on it and then save those changes. The table in quesiton has these columns: The code that does the updating is here: public void…
Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304
0
votes
1 answer

DateTime2 is driving me crazy

I'm using EF 4 (model First) in my project .NET and I having hard troubles with the DateTime fields. When I'll use SaveChanges() this exception is thrown: System.Data.SqlClient.SqlException : The conversion of a datetime2 data type to a datetime…
rochasdv
  • 539
  • 2
  • 8
  • 21
1 2 3
10
11