Converting a char data type to a DateTime data type resulted in a DateTime value out of range. Application completed.
ALTER PROCEDURE [dbo].[attendance_updatebyemployee_id]
@Employee_id int,
@AtDate datetime,
@FNLogged bit,
@ANLogged bit,
@LogTime varchar(10),
@LogOuttime varchar(10)
AS
BEGIN
SET NOCOUNT ON;
update Mst_Attendance set FNLogged=@FNLogged,
ANLogged=@ANLogged,LogTime=@LogTime,LogOuttime=@LogOuttime
where EmployeeId=@Employee_id and Atdate= @AtDate
END
in c # code i give it like
cmd.Parameters.AddWithValue("@AtDate",Dtime.ToString("dd/MMM/yyyy"));
when using SQl profiles. Past data
exec [dbo].[attendance_updatebyemployee_id] @Employee_id=2,@AtDate='Feb 19 2011 12:00:00:000AM',@FNLogged=1,@ANLogged=0,@LogTime='11:45 AM',@LogOuttime=' '
inside the stored procedure @AtDate matters 2011-02-19 00:00:00.000.
it breaks from the update command.
Inside the table, the date is saved as 2/19/2011 12:00:00 AM
How can I solve this problem with a date.
source
share