Adding todays date

Good morning all,

Does anyone know how to add today’s to a field on event of button click.

My current code which is working perfectly.

private void btnApprove_c_Click(object sender, System.EventArgs args)
{
	EpiDataView edvOrderHed = ((EpiDataView)(this.oTrans.EpiDataViews["OrderHed"]));
	if (edvOrderHed != null)
		{
			edvOrderHed.dataView.Table.Rows[0]["Approved_c"] = "Approved";
				oTrans.Update() ;
		}
}

}

I would like to add the “todays” date in dd/mm/yyyy to the a field on the same button click

edvOrderHed.dataView.Table.Rows[0][“ApprovedDate_c”] = “dd/mm/yyyy”;

Thanks :smiley:

DateTime.Now.ToString("dd/MM/yyyy")

How do I add that to the to the above code?

private void btnApprove_c_Click(object sender, System.EventArgs args)
{
	EpiDataView edvOrderHed = ((EpiDataView)(this.oTrans.EpiDataViews["OrderHed"]));
	if (edvOrderHed != null)
		{
			edvOrderHed.dataView.Table.Rows[0]["Approved_c"] = "Approved";
                        edvOrderHed.dataView.Table.Rows[0]["ApprovedDate_c"] = DateTime.Now.ToString("dd/MM/yyyy");
				oTrans.Update() ;
		}
}

1 Like

Legend, thank you Mark :slight_smile:

I’m getting this?

Any reason why?

image

Oh Ok - just drop the .ToString bit.

You just need:

DateTime.Now