Reputation: 32490
If I have a C# DateTime
object and a column in SQL Server of type Date
(not DateTime
)
For a stored procedure that takes in the date time from C# do I have any option other than passing in the C# DateTime
as a SQL Server DateTime
or can I pass it in of type Date
?
Upvotes: 0
Views: 757
Reputation: 166406
You could always use the DateTime.Date Property
Gets the date component of this instance.
Upvotes: 0
Reputation: 754598
Define it as a DATE
in your stored procedure
CREATE PROCEDURE dbo.YourProcedure (@FromDate DATE)
.....
and call it like this from C#:
yourSqlCmd.Parameters.Add("@FromDate", SqlDbType.Date);
yourSqlCmd.Parameters["@FromDate"].Value = yourDotNetDateTime.Date;
Upvotes: 1