?
Solved

UK Date Format in DW

Posted on 2005-03-18
4
Medium Priority
?
158 Views
Last Modified: 2010-04-25
Hi,

I have setup a site which a page which displays data from an Access database.  I have saved the page as all.cfm (i have coldfusion running on the server) and when I view the date column on the page it displays 2005-03-10 00:00:00 for example.  How can I make it display 10/03/2005 (dd/mm/yyyy)

Any help would be great.

Stuart
0
Comment
Question by:sr_millar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 13575036
You may need to try the DateFormat Fuction, like:

<cfset todayDate = Now()>
<body>
<h3>DateFormat Example</h3>
<p>Today's date is <cfoutput>#todayDate#</cfoutput>.
<p>Using DateFormat, we can display that date in different ways:
<cfoutput>
<ul>
  <li>#DateFormat(todayDate)#
  <li>#DateFormat(todayDate, "mmm-dd-yyyy")#
  <li>#DateFormat(todayDate, "mmmm d, yyyy")#
  <li>#DateFormat(todayDate, "mm/dd/yyyy")#
  <li>#DateFormat(todayDate, "dd/mm/yyyy")#
  <li>#DateFormat(todayDate, "d-mmm-yyyy")#  
  <li>#DateFormat(todayDate, "ddd, mmmm dd, yyyy")#  
  <li>#DateFormat(todayDate, "d/m/yy")#
</ul>  
</cfoutput>

cheers
0
 
LVL 7

Author Comment

by:sr_millar
ID: 13576269
Hi,

Thanks for answering:

Here is the code for my page,as you can see the date is put in the table by DW - I used the application object option to insert the dbase results.  Can you tell me how I amend my code with your function to disply the date column as dd/mm/yyyy?

<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfparam name="PageNum_All" default="1">
<cfquery name="All" datasource="QTS">

SELECT BusinessUnit, QuoteNo, MonthYear, QuoteDate, Company, Existing, ContPerson, Description, EquipCode, EndUseLoc, Status, IfLostTo, Comments, DayRateCurr, DayRateSter, PriceBook, DiscountRate, LongTermCalc, Period36912, Basis146198, Commission, CommisonRate, Agent, Probability
FROM Results
ORDER BY QuoteDate DESC
</cfquery>
<cfset MaxRows_All=10>
<cfset StartRow_All=Min((PageNum_All-1)*MaxRows_All+1,Max(All.RecordCount,1))>
<cfset EndRow_All=Min(StartRow_All+MaxRows_All-1,All.RecordCount)>
<cfset TotalPages_All=Ceiling(All.RecordCount/MaxRows_All)>
<cfset QueryString_All=Iif(CGI.QUERY_STRING NEQ "",DE("&"&XMLFormat(CGI.QUERY_STRING)),DE(""))>
<cfset tempPos=ListContainsNoCase(QueryString_All,"PageNum_All=","&")>
<cfif tempPos NEQ 0>
  <cfset QueryString_All=ListDeleteAt(QueryString_All,tempPos,"&")>
</cfif>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<table border="1" align="center">
  <tr>
    <td>BusinessUnit</td>
    <td>QuoteNo</td>
    <td>MonthYear</td>
    <td>QuoteDate</td>
    <td>Company</td>
    <td>Existing</td>
    <td>ContPerson</td>
    <td>Description</td>
    <td>EquipCode</td>
    <td>EndUseLoc</td>
    <td>Status</td>
    <td>IfLostTo</td>
    <td>Comments</td>
    <td>DayRateCurr</td>
    <td>DayRateSter</td>
    <td>PriceBook</td>
    <td>DiscountRate</td>
    <td>LongTermCalc</td>
    <td>Period36912</td>
    <td>Basis146198</td>
    <td>Commission</td>
    <td>CommisonRate</td>
    <td>Agent</td>
    <td>Probability</td>
  </tr>
  <cfoutput query="All" startRow="#StartRow_All#" maxRows="#MaxRows_All#">
    <tr>
      <td><a href="allquotes.cfm?recordID=#All.BusinessUnit#">#All.BusinessUnit# </a></td>
      <td>#All.QuoteNo# </td>
      <td>#All.MonthYear# </td>
      <td>#All.QuoteDate# </td>
      <td>#All.Company# </td>
      <td>#All.Existing# </td>
      <td>#All.ContPerson# </td>
      <td>#All.Description# </td>
      <td>#All.EquipCode# </td>
      <td>#All.EndUseLoc# </td>
      <td>#All.Status# </td>
      <td>#All.IfLostTo# </td>
      <td>#All.Comments# </td>
      <td>#All.DayRateCurr# </td>
      <td>#All.DayRateSter# </td>
      <td>#All.PriceBook# </td>
      <td>#All.DiscountRate# </td>
      <td>#All.LongTermCalc# </td>
      <td>#All.Period36912# </td>
      <td>#All.Basis146198# </td>
      <td>#All.Commission# </td>
      <td>#All.CommisonRate# </td>
      <td>#All.Agent# </td>
      <td>#All.Probability# </td>
    </tr>
  </cfoutput>
</table>
<br>
<table border="0" width="50%" align="center">
  <cfoutput>
    <tr>
      <td width="23%" align="center"><cfif PageNum_All GT 1>
          <a href="#CurrentPage#?PageNum_All=1#QueryString_All#">First</a>
        </cfif>
      </td>
      <td width="31%" align="center"><cfif PageNum_All GT 1>
          <a href="#CurrentPage#?PageNum_All=#Max(DecrementValue(PageNum_All),1)##QueryString_All#">Previous</a>
        </cfif>
      </td>
      <td width="23%" align="center"><cfif PageNum_All LT TotalPages_All>
          <a href="#CurrentPage#?PageNum_All=#Min(IncrementValue(PageNum_All),TotalPages_All)##QueryString_All#">Next</a>
        </cfif>
      </td>
      <td width="23%" align="center"><cfif PageNum_All LT TotalPages_All>
          <a href="#CurrentPage#?PageNum_All=#TotalPages_All##QueryString_All#">Last</a>
        </cfif>
      </td>
    </tr>
  </cfoutput>
</table>
<cfoutput>Records #StartRow_All# to #EndRow_All# of #All.RecordCount# </cfoutput>
</body>
</html>
0
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 1000 total points
ID: 13579975
i guess you need to format the value for column "QuoteDate" , right? try this:

<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfparam name="PageNum_All" default="1">
<cfquery name="All" datasource="QTS">

SELECT BusinessUnit, QuoteNo, MonthYear, QuoteDate, Company, Existing, ContPerson, Description, EquipCode, EndUseLoc, Status, IfLostTo, Comments, DayRateCurr, DayRateSter, PriceBook, DiscountRate, LongTermCalc, Period36912, Basis146198, Commission, CommisonRate, Agent, Probability
FROM Results
ORDER BY QuoteDate DESC
</cfquery>
<cfset MaxRows_All=10>
<cfset StartRow_All=Min((PageNum_All-1)*MaxRows_All+1,Max(All.RecordCount,1))>
<cfset EndRow_All=Min(StartRow_All+MaxRows_All-1,All.RecordCount)>
<cfset TotalPages_All=Ceiling(All.RecordCount/MaxRows_All)>
<cfset QueryString_All=Iif(CGI.QUERY_STRING NEQ "",DE("&"&XMLFormat(CGI.QUERY_STRING)),DE(""))>
<cfset tempPos=ListContainsNoCase(QueryString_All,"PageNum_All=","&")>
<cfif tempPos NEQ 0>
  <cfset QueryString_All=ListDeleteAt(QueryString_All,tempPos,"&")>
</cfif>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<table border="1" align="center">
  <tr>
    <td>BusinessUnit</td>
    <td>QuoteNo</td>
    <td>MonthYear</td>
    <td>QuoteDate</td>
    <td>Company</td>
    <td>Existing</td>
    <td>ContPerson</td>
    <td>Description</td>
    <td>EquipCode</td>
    <td>EndUseLoc</td>
    <td>Status</td>
    <td>IfLostTo</td>
    <td>Comments</td>
    <td>DayRateCurr</td>
    <td>DayRateSter</td>
    <td>PriceBook</td>
    <td>DiscountRate</td>
    <td>LongTermCalc</td>
    <td>Period36912</td>
    <td>Basis146198</td>
    <td>Commission</td>
    <td>CommisonRate</td>
    <td>Agent</td>
    <td>Probability</td>
  </tr>
  <cfoutput query="All" startRow="#StartRow_All#" maxRows="#MaxRows_All#">
    <tr>
      <td><a href="allquotes.cfm?recordID=#All.BusinessUnit#">#All.BusinessUnit# </a></td>
      <td>#All.QuoteNo# </td>
      <td>#All.MonthYear# </td>
      <td>#DateFormat(All.QuoteDate, "dd/mm/yyyy")# </td>
      <td>#All.Company# </td>
      <td>#All.Existing# </td>
      <td>#All.ContPerson# </td>
      <td>#All.Description# </td>
      <td>#All.EquipCode# </td>
      <td>#All.EndUseLoc# </td>
      <td>#All.Status# </td>
      <td>#All.IfLostTo# </td>
      <td>#All.Comments# </td>
      <td>#All.DayRateCurr# </td>
      <td>#All.DayRateSter# </td>
      <td>#All.PriceBook# </td>
      <td>#All.DiscountRate# </td>
      <td>#All.LongTermCalc# </td>
      <td>#All.Period36912# </td>
      <td>#All.Basis146198# </td>
      <td>#All.Commission# </td>
      <td>#All.CommisonRate# </td>
      <td>#All.Agent# </td>
      <td>#All.Probability# </td>
    </tr>
  </cfoutput>
</table>
<br>
<table border="0" width="50%" align="center">
  <cfoutput>
    <tr>
      <td width="23%" align="center"><cfif PageNum_All GT 1>
          <a href="#CurrentPage#?PageNum_All=1#QueryString_All#">First</a>
        </cfif>
      </td>
      <td width="31%" align="center"><cfif PageNum_All GT 1>
          <a href="#CurrentPage#?PageNum_All=#Max(DecrementValue(PageNum_All),1)##QueryString_All#">Previous</a>
        </cfif>
      </td>
      <td width="23%" align="center"><cfif PageNum_All LT TotalPages_All>
          <a href="#CurrentPage#?PageNum_All=#Min(IncrementValue(PageNum_All),TotalPages_All)##QueryString_All#">Next</a>
        </cfif>
      </td>
      <td width="23%" align="center"><cfif PageNum_All LT TotalPages_All>
          <a href="#CurrentPage#?PageNum_All=#TotalPages_All##QueryString_All#">Last</a>
        </cfif>
      </td>
    </tr>
  </cfoutput>
</table>
<cfoutput>Records #StartRow_All# to #EndRow_All# of #All.RecordCount# </cfoutput>
</body>
</html>

that's basically replace:

#All.QuoteDate#

to:

#DateFormat(All.QuoteDate, "dd/mm/yyyy")#

Apply this to your other columns if you want to format it with DateFormat function, cheers
0
 
LVL 7

Author Comment

by:sr_millar
ID: 13589399
Spot on, worked first time - many thanks.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

770 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