2 different date formats in a Coldfusion if statement

23 07 2007

So I was pulling in date entries from a MySQL database and needed to display the date differently via Coldfusion depending on which group the entry belonged to. For the “yearly” entries, I only wanted to show the year, for the rest, I wanted the standard “7/22/2007″ format. The solution? Put in a cfif that checked to see which group the entry belonged to. Depending on which one, the varaible would be formatted differently, like so:

<cfif #VARIABLES.subSelected# is 3>
<cfset formatdate = dateformat(date, “yyyy”)>
<cfelse>
<cfset formatdate = dateformat(date, “m/d/yyyy”)>
</cfif>


Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s




Follow

Get every new post delivered to your Inbox.