473,485 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem: ColdFusion - displaying data from a certain period

4 New Member
Hi, could someone please help me? I am a novice so please try to be patient.
I've created a database to hold members who join my website. I've created the form to enable them to join and their data goes into the database. I've managed to use ColdFusion to display a list of all members.
But I want to refine this list, to only show members who joined this year. How do I do this? Becuase I've tried everything I can think of.
Here's my current code for the page that produces the list of those in who joined in 2007:

Expand|Select|Wrap|Line Numbers
  1. <!---newmemberslist.cfm list of all members joined in 2007--->
  2.  
  3. <html>
  4. <head>
  5. <title>Admin Area - List all Members joined in 2007</title>
  6. </head>
  7.  
  8. <body bgcolor=beige>
  9. <CFQUERY name="newmemberslist" DATASOURCE = "jpkelle2-access">
  10. SELECT memberID, forename, initial, surname, sex, dob, address, town, county, postCode, email, joinDate
  11. FROM members
  12. WHERE joinDate > 01/01/2007
  13. </CFQUERY>
  14.  
  15. <h1><center>Members</h1>
  16. <h2>New Members in 2007</h2>
  17.  
  18. <p>
  19. <table border=1 bgcolor="beige" cellpadding="3" cellspacing="0">
  20. <tr>
  21. <th>Member ID</th>
  22. <th>Name</th>
  23. <th>Sex</th>
  24. <th>Date of Birth</th>
  25. <th>Address</th>
  26. <th>Email</th>
  27. <th>Date Joined</th>
  28. </tr>
  29.  
  30. <CFOUTPUT Query="newmemberslist">
  31.  
  32.  
  33. <tr>
  34. <td><center>#memberID#<center></td>
  35. <td width="15%">#forename# #initial# #surname#</td>
  36. <td>#sex#</td>
  37. <td>#dob#</td>
  38. <td>#address#, #town#, #county#, #postCode#</td>
  39. <td>#email#</td>
  40. <td>#joinDate#</td>
  41. </tr>
  42.  
  43.  
  44.  
  45.  
  46. </CFOUTPUT>
  47.  
  48. </table>
  49.  
  50. <hr><p>End of members list.</p>
  51.  
  52. </body>
  53. </html>

When I execute this it doesn't seem to treat '01/01/2007' as a date, even though I've used the format 'date/time' in Access.
Is it a problem with my code or with my Access design?

thanks, James
Apr 4 '07 #1
4 2906
acoder
16,027 Recognized Expert Moderator MVP
James, welcome to TSDN.

Try the year function:
Expand|Select|Wrap|Line Numbers
  1. <CFQUERY name="newmemberslist" DATASOURCE = "jpkelle2-access">
  2. SELECT memberID, forename, initial, surname, sex, dob, address, town, county, postCode, email, joinDate
  3. FROM members
  4. WHERE year(joinDate) = 2007
  5. </CFQUERY>
Tip: why not make a generic page, e.g. either through a url variable, or use year(now()) to get the members who joined in the current year, so you don't need to change it every year!
Apr 4 '07 #2
James890
4 New Member
thanks so much for that.
it works, but......the displayed data has rearranged the date format to
yyyy-mm-dd
why has it done this? can I not get it to be dd-mm-yyyy again?

also, how can I get rid of the time next to the date
(eg it displays - 2007-01-12 00:00:00.0) I don't want the time to be displayed.
Can I not get rid of it seeing I have the field as 'date/time' in Access?
Apr 4 '07 #3
James890
4 New Member
Does it not really matter if a date in Access is defined as 'text' in the data type column, rather than date/time.

Because if I set joinDate as 'text' in Access then it works OK. I get just the date and not the time as well, and I get in the format dd/mm/yyyy, which is what I want.

Is it OK that I've used the text format rather than date/time, or will this produce errors somewhere along the line?
Apr 4 '07 #4
acoder
16,027 Recognized Expert Moderator MVP
Does it not really matter if a date in Access is defined as 'text' in the data type column, rather than date/time.

Because if I set joinDate as 'text' in Access then it works OK. I get just the date and not the time as well, and I get in the format dd/mm/yyyy, which is what I want.

Is it OK that I've used the text format rather than date/time, or will this produce errors somewhere along the line?
No keep it as date/time and use the coldfusion dateformat function. You can use a mask, e.g. "dd/mm/yyyy" to format the date as you wish.
Apr 5 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

60
9979
by: English Teacher | last post by:
Which would be more useful to learn, PHP or COLDFUSION? I know Coldfusion is popular in the work force. Is PHP? Thanks!
1
1378
by: kuhni | last post by:
Hi everybody! Writing this time, I'm really desperate. Basically, I have a conceptual problem of how to solve a certain "problem" in MS Access 97. General objective: In order to categorise...
3
23030
acoder
by: acoder | last post by:
How to Upload a File in Coldfusion Use the cffile tag for uploading files to the server. Note that allowing people to upload files is fraught with danger and only trusted users should be...
16
2346
by: Victor | last post by:
I have a strange problem in my website. I configured my website to run under 2 worker processes. (web garden enabled). and I stored my user information in the current httpcontext(like...
1
3936
by: James890 | last post by:
I want to enable a user to enter a start and end date to define the period they want to search for records of members who joined on certain dates. Funny thing is...I've got it to work half of the...
8
13588
by: jesmi | last post by:
my code is: addRecord.cfm <cfinclude template="head.cfm"> <p> <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <td> <div align="center">
7
8767
by: kmitchell00 | last post by:
I am coding in Coldfusion MX7 and using Javascript for some of the functionality. The basic functionality I'm coding is, based on a value the user chooses from a dropdown box, I populate address...
3
6449
by: Blackmore | last post by:
Following the guidance contained in Dreamweaver, I have declared a cflogin tag in the application.cfc file. This declaration contains an idletimeout setting of 10 seconds (N.B. 10 seconds for...
1
4077
by: johnVarma | last post by:
Hi All, Iam facing a problem with bar chart using coldFusion. if there is only one <cfchartseries> tag then the seriesLabel attribute is not displaying instead of that the items of the...
0
6960
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7161
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6825
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7275
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5418
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4551
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3058
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1376
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
595
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.