[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Date format in ColdFusion

Posted on 2010-03-30
2
Medium Priority
?
287 Views
Last Modified: 2013-12-16
I have a used ‘CFGRID’ with ‘CFGRIDCOLUMN’ using the ‘parks’ from ‘cfdocexamples ‘database
In the code I pull in the dateestb field and all works fine. I need to format the date to display dd ddd mmm yyy.
How can I do this, can anyone help.
( I have attached code I am using in 2 pages, a cfm and a cfc)
<!--- Code saved as demo.cfm --->

<cfform name="parkForm">
	<cfgrid format="html" name="parkGrid" pagesize="10" selectmode="row" bind="cfc:calender.getParks({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})">
		<cfgridcolumn name="parkName" width="300" header="Name" />
		<cfgridcolumn name="parkType" width="180" header="Type" />
		<cfgridcolumn name="city" width="120" header="City" />
		<cfgridcolumn name="state" width="60" header="State" />
        <cfgridcolumn name="dateestb" width="150" header="Date Est" />
	</cfgrid>
</cfform>
<!--- End Code saved as demo.cfm --->

<!--- Code saved as calender.cfc --->
<cffunction name="getParks" access="remote" returntype="struct">
	<cfargument name="page" required="true" />
	<cfargument name="pageSize" required="true" />
	<cfargument name="gridsortcolumn" required="true" />
	<cfargument name="gridsortdirection" required="true" />
	
	<cfif arguments.gridsortcolumn eq "">
		<cfset arguments.gridsortcolumn = "parkName" />
		<cfset arguments.gridsortdirection = "asc" />
	</cfif>

	<cfquery name="parks" datasource="cfdocexamples">
		select		parkName, parkType, city, state, dateestb
		from		parks
		order by	#arguments.gridsortcolumn# #arguments.gridsortdirection#
	</cfquery>

	<cfreturn queryconvertforgrid(parks, page, pagesize) />
</cffunction>
<!--- End Code saved as calender.cfc --->

Open in new window

0
Comment
Question by:john_hollings
2 Comments
 
LVL 27

Accepted Solution

by:
azadisaryev earned 1500 total points
ID: 29082387
there are 2 ways you can approach this:

1) use db-specific date functions to get the date in preferred format from db.
unfortunately, apache derby db (which is the db of the cfdocexamples that ships with cf8+) does not have necessary built-in functions to return a date in your preferred format. but other dbs (ms sql, mysql, etc) all have them

for an explanation and example read this:
http://www.garyrgilbert.com/blog/index.cfm/2007/7/3/QueryConvertForGrid-date-format-woes

2) use a custom grid cell renderer to re-format the date cell in your preferred format.
explanation and example can be found here:
http://www.coldfusionguy.com/ColdFusion/blog/index.cfm/2007/11/27/CFGrid-Custom-Date-Renderer

Azadi
0
 
LVL 5

Author Closing Comment

by:john_hollings
ID: 31708841
Tanks
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this short web based tutorial, I wanted to show users how they can still use the powers of FrontPage in conjunction with Expression Web 3.  Even though Microsoft eliminated the use of Web components, we can still use them with FrontPage and edit …
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
Suggested Courses

590 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question