how to format a date/time using bind

Author: Diego Benitez
Date: 3/10/05
CFM: Coldfusion MX 7

Here is the only that i have found to format date/time values coming from a database into the new flash forms on MX 7.

When using <cfformgroup type="repeater" query="queryname"> insted of <cfloop query="">
if avoids the server of compiling the swf file again. Saving sever time and just using a actionscript loop to populate the values throu remoteflash port so if you start guesing how to pull data from the query you have to use the atribute "bind"

Normally you call the value this way 
<cfformgroup type="repeater" query="queryname">
    <cfinput name=
"anyname" bind="{queryname.currentItem.yourtable}">
</cfformgroup>


insted of 
<cfloop query="queryname">
    <cfinput name=
"anyname" value="#queryname.yourtable#">
</cfloop>


So here for formatting your date/time use the following inside "bind" attribute

{queryname.currentItem.Updatedon.getMonth()}/{queryname.currentItem.Updatedon.getDate()}/{queryname.currentItem.Updatedon.getFullYear()} {((queryname.currentItem.Updatedon.getHours()%12) == 0) ? '12' : queryname.currentItem.Updatedon.getHours()}:{queryname.currentItem.Updatedon.getMinutes()} {(queryname.currentItem.Updatedon.getHours()<12) ? 'AM' : 'PM'}

Unfortunatelly ColdFusion doesn't let you create functions that can be compiled with the flash file so most of our statements have to be inside that line.
thats why all the line is long.

let brake down the code... lets take as example the month

{queryname.currentItem.Updatedon.getMonth()}

queryname = this will be your query name used on <cfquery name="">

currentitem = this tells flash that you are refering to the current row, basically this is the index.

updateon = is just a table that i created to hold the ODBCdatetime

getMonth() = this is a element of flash, if you want to go crazy using more of these get a flash MX book, i used the "FLASH MX Professional 2004 application development" or here is the online dictionary of flash
http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/index.html 

remember everything between {} is value, you use these insted of the ## for ColdFusion. Everything outside them is read as just text.

Good luck and if you find a better way to do this please let me know...



All ColdFusion Tutorials By Author: Diego Benitez
  • Format your date in spanish.
    This is a custom tag to translate the regular english output of a date into spanish like (20 de Enero de 2004) and as you want it to be.
    Author: Diego Benitez
    Views: 9,734
    Posted Date: Thursday, January 29, 2004
  • how to format a date/time using bind
    here is a long way but the only one i found to format a date/time using the <cfformgroup type="repeater" query="queryname">
    Author: Diego Benitez
    Views: 7,773
    Posted Date: Thursday, March 10, 2005
  • QueryStringSet
    Replaces or Adds a variable with its value on a cgi.Query_String alike. It supports multiple values at the same time separated by commas
    Author: Diego Benitez
    Views: 5,959
    Posted Date: Wednesday, January 11, 2006