Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

UK Date Format in DW

Posted on 2005-03-18
4
Medium Priority
?
162 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
  • 2
  • 2
4 Comments
 
LVL 55

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 55

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
Screencast - Getting to Know the Pipeline
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

577 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