Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 15, 2012 07:29 PM by Curt_C
Member
108 Points
313 Posts
Nov 15, 2012 05:24 PM|LINK
How do you pass a date parameter with value '1753-01-01 00:00:00.000' to a stored procedure using C#?
I tried DateTime.MinValue, but that doesn't work.
All-Star
66017 Points
7639 Posts
Moderator
Nov 15, 2012 05:26 PM|LINK
That isn't DateTime.MinValue, that's why.
Just pass it as a string, SQL should interpret it fine.
Nov 15, 2012 05:29 PM|LINK
I know, I tried MinValue and when the program calls the SP, I get:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
Nov 15, 2012 06:25 PM|LINK
This worked:
DateTime.MinValue.AddYears(+1752)
Nov 15, 2012 07:29 PM|LINK
You're using .NET Datetime, use SQLDateTime instead
instead of: DateTime.MinValue
Use: System.Data.SqlTypes.SqlDateTime.MinValue
lesponce
Member
108 Points
313 Posts
Set Date to 1753-01-01 00:00:00.000
Nov 15, 2012 05:24 PM|LINK
How do you pass a date parameter with value '1753-01-01 00:00:00.000' to a stored procedure using C#?
I tried DateTime.MinValue, but that doesn't work.
Curt_C
All-Star
66017 Points
7639 Posts
Moderator
Re: Set Date to 1753-01-01 00:00:00.000
Nov 15, 2012 05:26 PM|LINK
That isn't DateTime.MinValue, that's why.
Just pass it as a string, SQL should interpret it fine.
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!
lesponce
Member
108 Points
313 Posts
Re: Set Date to 1753-01-01 00:00:00.000
Nov 15, 2012 05:29 PM|LINK
I know, I tried MinValue and when the program calls the SP, I get:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
lesponce
Member
108 Points
313 Posts
Re: Set Date to 1753-01-01 00:00:00.000
Nov 15, 2012 06:25 PM|LINK
This worked:
DateTime.MinValue.AddYears(+1752)
Curt_C
All-Star
66017 Points
7639 Posts
Moderator
Re: Set Date to 1753-01-01 00:00:00.000
Nov 15, 2012 07:29 PM|LINK
You're using .NET Datetime, use SQLDateTime instead
instead of:
DateTime.MinValue
Use:
System.Data.SqlTypes.SqlDateTime.MinValue
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!