locked
System Date RRS feed

  • Question

  • User-797751191 posted

    Hi

      I have below Update command and i want to update current date also in the system with Status field n this Update command

    using (SqlCommand cmdApprove = new SqlCommand("Update test SET Status = 'A' where [Doc No] = @DocNo", con))
    {
    cmdApprove.CommandType = CommandType.Text;

    cmdApprove.Parameters.AddWithValue("@DocNo", txtDocumentNo.text);

    Thanks

    Sunday, August 11, 2019 2:53 PM

All replies

  • User-719153870 posted

    Hi jsshivalik,

    i want to update current date also in the system with Status field

    Are you trying to update your date field to today's date at the same time you update your status field? If so, please refer to  below code:

    Update test SET Status = 'A',[date]=GETDATE() where [Doc No] = @DocNo

    Or, are you trying to update the date field after you update the staus field? Like below:

    Update test SET Status = 'A' where [Doc No] = @DocNo;Update test SET [date]=GETDATE() where Status = 'A'

    Best Regard,

    Yang Shen

    Monday, August 12, 2019 2:43 AM