Format Text Box to Date

I have a BAQ Data View on a Dashboard and a text box is bound to the Ship Date field. I would like for that textbox to be formatted with just the date and not the time.

image

epiTextBox11.Text is the one that is bound. I have tried setting Extended Properties and it isn’t working. This is that code:

private void SetExtendedProperties()
	{
		// Begin Wizard Added EpiDataView Initialization
		EpiDataView edvGS_Order_Detail_DataView = ((EpiDataView)(this.oTrans.EpiDataViews["GS_Order_Detail_DataView"]));
		// End Wizard Added EpiDataView Initialization

		// Begin Wizard Added Conditional Block
		if (edvGS_Order_Detail_DataView.dataView.Table.Columns.Contains("OrderDtl_RequestDate"))
		{
			// Begin Wizard Added ExtendedProperty Settings: edvGS_Order_Detail_DataView-OrderDtl_RequestDate
			edvGS_Order_Detail_DataView.dataView.Table.Columns["OrderDtl_RequestDate"].ExtendedProperties["Format"] = "shortyeardate";
			// End Wizard Added ExtendedProperty Settings: edvGS_Order_Detail_DataView-OrderDtl_RequestDate
		}
1 Like

MyDateTime.ToString(dd-MM-yyyy);

You can use it in a format: MyGrid.DisplayLayout.Bands[0].Columns[ColumnDate].Format = “dd-MM-yyyy”;

Okay, I’m sorry, I’m not understanding what I do with what you sent me. I tried this but it isn’t working.

	{
		// Begin Wizard Added EpiDataView Initialization
		EpiDataView edvGS_Order_Detail_DataView = ((EpiDataView)(this.oTrans.EpiDataViews["GS_Order_Detail_DataView"]));
		// End Wizard Added EpiDataView Initialization

		// Begin Wizard Added Conditional Block
		if (edvGS_Order_Detail_DataView.dataView.Table.Columns.Contains("OrderDtl_RequestDate"))
		{
			// Begin Wizard Added ExtendedProperty Settings: edvGS_Order_Detail_DataView-OrderDtl_RequestDate
			edvGS_Order_Detail_DataView.dataView.Table.Columns["OrderDtl_RequestDate"].ExtendedProperties["Format"] = "dd-MM-yyyy";
			// End Wizard Added ExtendedProperty Settings: edvGS_Order_Detail_DataView-OrderDtl_RequestDate
		}

And this
epiTextBox11.Text.ToString(dd-MM-yyyy);
And I get errors about :slight_smile: Error: CS0103 - line 757 (11524) - The name ‘dd’ does not exist in the current context
Error: CS0103 - line 757 (11524) - The name ‘MM’ does not exist in the current context
Error: CS0103 - line 757 (11524) - The name ‘yyyy’ does not exist in the current context

Ok, let me back up. Ignore the the part about ToString, thats how you pull the date from a DateTime.

Where is the code being called?

Is there a reason you are using a text box and not the DateTime Control?

You forgot the " =)

MyDateTime.ToString("dd-MM-yyyy");

I would use the DateTime Control.

Because the box is displaying a data view and on load it errors out if I change the box to a date time box.

I am calling it when after I publish an order number to the BAQ Data View. It then brings all my order information into text boxes. I want that text box to format as a date and not show the time.

I dont understand this issue. The solution to your problem is definitely best solved by using that DateTime control. You would use that control and set the binding to EDVName.FieldName

I was getting errors but not anymore. I just attached it to the data view using a date box and it worked. Not sure why it errored out before.

1 Like