I have a question .. I have a method that receives several dates in datetime format (dd / mm / yyyy)
Something like that
public ActionResult Reports(DateTime? FechaInicio, DateTime? FechaFin, DateTime? IptSemana, DateTime? IptDia)
At the moment of executing the SP, I send the parameters in the following way:
cmd.Parameters.Add("@FechaInicio", SqlDbType.DateTime).Value = FechaInicio; //? (object)DBNull.Value : FechaFin);
cmd.Parameters.Add("@FechaFin", SqlDbType.DateTime).Value = FechaFin; //? (object)DBNull.Value : FechaFin);
cmd.Parameters.Add("@FechaSemana", SqlDbType.DateTime).Value = IptSemana;// ? (object)DBNull.Value : IptSemana);
cmd.Parameters.Add("@FechaDia", SqlDbType.DateTime).Value = IptDia;// ? (object)DBNull.Value : IptDia);
How can I change the date format to MM / dd / yyyy if I get an error that the datetime is nulleable