I have a sql procedure which is outputting the following @startdate as a datetime output. I am trying to get these values into my C# aspx.cs code.
C# Output parameters
cmd5.Parameters.Add(new SqlParameter("@startdate", SqlDbType.DateTime, 100, ParameterDirection.Output, false, 0, 10, "startdate", DataRowVersion.Default, null));
I have a public variable called startdate and trying to assign the above output parameter to the variable as seen below:
startdate = DateTime.Parse(cmd5.Parameters["@startdate"].Value.ToString()); //output is {01/12/2017 00:00:00} (correct date coming from sql, wrong format)
I need to parse this variable into another procedure from the front end. This procedure expects nvarchar(35) in sql format: yyyy-MM-dd hh:MM:ss
How do i parse the above startdate global variable to the sql format in nvarchar(35) from here?