I have this SQL command and the aplydate and glpostdt fields are dates.
DataCommand.CommandText = "select aplydate,glpostdt,distref from job_linker where companyid = '" + CompanyID + "' and bchsourc = 'Apply_Documents' and transnmbr ='" + ApplyToVoucherNumber + "' and trxtype = 'Apply Payments ' and dstsqnum = 16384 and cntrltyp = 0 and aptvchnm = '" + ApplyToDocumentNumber + "' and spcldist = 0 and len(rtrim(jobnumber))>0";
I obtain the values with this code
DataDataAdapter = new System.Data.SqlClient.SqlDataAdapter();
DataDataAdapter.SelectCommand = DataCommand;
DataDataAdapter.TableMappings.Add("Table", "DISTREF");
this.txtApplyDate.DataBindings.Add("Text", DataDataSet.Tables["DISTREF"], "aplydate").ToString();
this.txtApplyPostingDate.DataBindings.Add("Text", DataDataSet.Tables["DISTREF"], "glpostdt").ToString();
It is the last two lines where I am stumped. I want the format of the dates to be MM/dd/yyyy. When I try
this.txtApplyDate.DataBindings.Add("Text", DataDataSet.Tables["DISTREF"], "aplydate").ToString("MM/dd/yyyy")
I receive an error.
What is the correct way to format these date fields?