menu
Login
Register
search
Log In
account_circle
Log In
Email or Username
Password
Remember
Log In
Register
I forgot my password
Register
Username
Email
Password
Register
add
Q&A
Questions
Unanswered
Tags
Users
Ask a Question
Articles
Interview Questions
Programming Quiz
Post An Article
Recent Posts
Python show image
Best CSS Frameworks for Front-End Developers
POP first element of list python
POP last elements of list python
Program the Time Warner cable remote for a Sharp LCD TV?
Innovage Jumbo Universal Remote Control Instructions
Automatically search for a remote control code for DirecTV
Program an RCA Universal Remote for a Samsung TV
Creating a miniax ai for TicTacToe in js
How do universal remotes work?
the conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
0
votes
213
views
Problem :
I am getting bellow error related to datetime
the conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
c#
sql-server
entity-framework
datetime
asked
Nov 7, 2019
peterlaw
●
6
●
5
●
3
6,930 points
answer
Please
log in
or
register
to answer this question.
1
Answer
0
votes
Solution :
I think both the DATETIME and DATETIME2 map to System.DateTime in .NET So you cannot really do a "conversion", as it is really the same .NET type.
Also please note that there are two different values for the "SqlDbType" for these two.
On SQL Server the date range supported is quite different.
DATETIME supports 1753/1/1 to 9999/12/31, while DATETIME2 supports 0001/1/1 through eternity.
So what you really need to do is check for the year of the date and if it is before 1753, you need to change it to after 1753 in order for the DATETIME column in SQL Server to handle it.
answered
Nov 8, 2019
AbhijitJ
●
9
●
7
●
4
38,600 points
ask related question
comment
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
What is the color of the sky?
To avoid this verification in future, please
log in
or
register
.
Add comment
Cancel
Related questions
0
votes
1
answer
78
views
78
views
the conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
Problem : I was getting the following error when running a SQL the conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
asked
Nov 12, 2019
peterlaw
6.9k
points
sql-server
tsql
datetime
0
votes
1
answer
12
views
12
views
The transformation of a datetime2 data type to a datetime data type resulted in an out-of-range value.
Problem: The transformation of a datetime2 data type to a datetime data type resulted in an out-of-range value.
asked
Feb 23
Muneeb Saadii
125k
points
0
votes
1
answer
1
view
1
view
The underlying provider failed on open.
Problem: I get the error: The underlying provider failed on Open
asked
Mar 20
ummesalma
22k
points
c#
sql-server
entity-framework
0
votes
1
answer
14
views
14
views
How to return to the date only part of a SQL Server datetime data type
Problem: select GETDATE() Returns: 2008-09-22 15:24:13.790 I want the date part, without the time part:2008-09-22 00:00:00.000
asked
Feb 15
sasha
16.2k
points
date
datetime
1
vote
1
answer
4
views
4
views
The entity or complex type cannot be constructed in a linq to entities query.
Problem: Need help with the usage of entities , I am facing this issue. The entity or complex type cannot be constructed in a linq to entities query.
asked
Mar 26
PkGuy
13.1k
points
c#
entity-framework
database
0
votes
1
answer
94
views
94
views
The entity or complex type cannot be constructed in a linq to entities query
Problem : I have one entity type called product which is generated by the entity framework. I have tried to write below query public IMyQueryable<Product> GetProducts(int myCategoryID) { return from prod in db.Products where prod.CategoryID== myCategoryID select ... one select new Product { Name = p.Name}; it miraculously works correctly. How can I perform the custom select section?
asked
Jan 27, 2020
jwilliam
3.9k
points
c#
entity-framework
0
votes
1
answer
5
views
5
views
String was not recognized as a valid datetime.
Problem: I am trying to convert my string formatted value to date type with the format dd/MM/yyyy. this.Text="22/11/2009"; DateTime date = DateTime.Parse(this.Text); What is the problem?
asked
Mar 22
ummesalma
22k
points
c#
net
datetime
types
casting
0
votes
2
answers
417
views
417
views
The entity type applicationuser is not part of the model for the current context.
Problem : Currently I am migrating from the Identity 1.0.0 to Identity 2.0.1. But the migrations code generated is nothing about the new IdentityUser. And It does not even add the new columns. So I tried to make the new project and also I ... current context At below line IdentityResult result = await UserManager.CreateAsync(user, model.Password); Any clue about the solution on my above problem?
asked
Dec 25, 2019
alecxe
7.5k
points
c#
asp
net
entity-framework
net-identity
0
votes
1
answer
4
views
4
views
To store a date value without storing a time value, you can use the
Problem: I want to store times in a database table but only need to store the hours and minutes. I know I could just use DATETIME and ignore the other components of the date, but what's the best way to do this without storing more info than I actually need?
asked
Mar 17
ummesalma
22k
points
sql-server
database
database-design
datetime
0
votes
1
answer
37
views
37
views
How to retrieve data from database using entity framework in mvc?
Problem: Currently I have the table called Student in the database with some of the values and I am trying to display the values in the webgrid with the help of entityframework. I have done exactly the same kind of work before many times using the Ado.net, but ... I assign the VAR value to List also is this my correct approach? Kindly guide me in fixing my problem related to Entity Framework.
asked
Jul 3, 2020
Raphael Pacheco
4.9k
points
c#
entity-framework
asp
net-mvc-4