Skip to main content
Participating Frequently
February 25, 2011
Question

Formatting date input text

  • February 25, 2011
  • 2 replies
  • 900 views

OK - I found the way to format the datetime from MS SQL Server (2008) in my cfgrid column. So in the grid column cells the date shows as 02/25/11. There are several columns with dates that are not displayed - I checked those and in the cfgrid column they display as 02/25/11. However, I have input text boxes which bind to those not displayed column fields and the dates in those text boxes display as Fri Feb 25 00:00:00 EST 2011. How do I format the input text boxes to display dates in the following format - 02/25/11? Or at least, how to I get the input text boxes to display exactly in the same format as the dates in the cfgrid?

Greatly appreciate working suggestion.

Thanks - JS

BTW - code for input text boxes is

<td><cfinput type="text" name="BeginDate" bind="{reqInfo.BeginDate}" readonly="true" width="100px" ></td>
  <td><cfinput type="text" name="EndDate" bind="{reqInfo.EndDate}" readonly="true" width="100px" ></td>

Code for cfgrid for "BeginDate" and "EndDate" as follows: (see last two lines)

<cfgrid name="reqInfo" query="Req" width="510" visible="yes" format="html" rowheaders="yes" rowheaderwidth="50" selectcolor="orange" selectmode="row" maxrows="30" colheaderbold="yes" colheadertextcolor="Blue" selectOnLoad="no">
  <cfgridcolumn name="ID" width="8" display="no" />
  <cfgridcolumn name="PIN" display="no" />
  <cfgridcolumn name="Name" header="Name" headerfontsize="14px" width="150" />
  <cfgridcolumn name="RequestDate" header="Request Date" dataalign="center" headerfontsize="14px" width="115" mask="m/d/y" type="date"/>
  <cfgridcolumn name="BeginDate" header="Begin Date" display="no" headerfontsize="14px" width="90" mask="m/d/y" type="date"/>
  <cfgridcolumn name="EndDate" header="End Date" display="no" headerfontsize="14px" width="90" mask="m/d/y" type="date"/>

    This topic has been closed for replies.

    2 replies

    Inspiring
    February 25, 2011

    Within ms sql you can use cast or convert to format dates.  Also within ms sql you have isnull and coalesce functions to ensure that every row has a value in every field.

    Inspiring
    February 25, 2011

    Disclaimer: I have not tested any of these options.


    Things to try:

    1. Use the mask attribute of CFINPUT.   I'm not sure if the mask attribute will format a bound variable's value.  I suspect it does not, but it is worth a try.

    2. Wrap the bound variable in a DateFormat function.  Example: bind="{DateFormat(reqInfo.EndDate, 'mm/dd/yyyy')}"  I'm not sure if this is valid syntax.