i can write the stored procedure delete the row in table based on date
create proc uspInvoicePaymentsdelete3
@PaymentDate datetime
as
begin
delete from tblInvoicePaymentDetails where PaymentDate=@PaymentDate
end
but row not deleted i am sending parameter value is ‘6/15/2011 3:40:18 PM’ but It taking 24hours format in my sql server2005 so no rows are deleted how to change the dates.(table date format and parameter date is same format but stored procedure converting 24 hr format)
delete from tblInvoicePaymentDetails where PaymentDate='6/15/2011 3:40:18 PM'
but my requirement is datetime consider secounds also ,
- problem is i am sending parameter date and database date both same but output is no rows deleted what is the problem and how to write the stored procedure
Pls give me correct solution
Name Date amount id
hemanth 6/15/2011 3:40:18 PM 100 1003
hemanth 6/15/2011 3:40:42 PM 100 1003
Thanking u
hemanth
The problem may be related to the fact that, as @Andrew has pointed out in his comment to your question, datetime values in your table contain milliseconds also, while you are passing the value that doesn’t contain milliseconds.
If that is so, you could change the WHERE clause of you DELETE statement like this:
Note, though, that this may lead to deleting more than one row. For example, you have data as follows:
If we ignore milliseconds, then there are two rows here with the same value of
PaymentDate. Maybe, a situation like this is impossible with your application and so you needn’t worry about that. I just wanted to make sure that you were aware that, technically, it could be possible to delete more than one record when you are using an incomplete date/time value as a parameter.