ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old April 21st, 2004, 11:55 AM
mike_uk mike_uk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 9 mike_uk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m
Reputation Power: 0
Retreiving date information from tables

Hi all I'm using SQL and ColdFusion to make a query the retreives a set of dates from my database. I have a table called ORDERS that has a fieldname of OrderDate and I want to find all orders in the year 2004, there is only one order in 2003.

I have tried using SELECT OrderDate FROM ORDERS WHERE OrderDate BETWEEN 1-1-2004 AND 31-12/2004 but this didn't work for me. I have recently tried
SELECT OrderDate
FROM ORDERS
WHERE (ORDERS.OrderDate > #"31-12-2003"#) but again this still outputs the order from year 2003 and have looked on many tutorials but can't find the right combination.


Could anyone help me at all?

Reply With Quote
  #2  
Old April 21st, 2004, 12:53 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,488 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 10 m 11 sec
Reputation Power: 42
Is orderDate a TRUE date/time field, or is it a string field that happens to be holding a date? You'll have to look at the data type of the column to confirm this.

If it IS an actual date/time field, you can try using createODBCDate() to format the date correctly.

Reply With Quote
  #3  
Old April 21st, 2004, 01:02 PM
mike_uk mike_uk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 9 mike_uk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m
Reputation Power: 0
date/time

Quote:
Originally Posted by kiteless
Is orderDate a TRUE date/time field, or is it a string field that happens to be holding a date? You'll have to look at the data type of the column to confirm this.

If it IS an actual date/time field, you can try using createODBCDate() to format the date correctly.



I've just had a look at the table and OrderDate has a data type of date/time, does that clarify this issue for you?

Reply With Quote
  #4  
Old April 21st, 2004, 02:13 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,488 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 10 m 11 sec
Reputation Power: 42
I would try something like:

SELECT OrderDate
FROM ORDERS
WHERE (ORDERS.OrderDate > #createODBCDate( "12/31/2003" )#)

Also confirm that the less than sign means dates AFTER the specified date. You may need to use < instead, I just don't remember.

Reply With Quote
  #5  
Old April 21st, 2004, 02:54 PM
mike_uk mike_uk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 9 mike_uk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m
Reputation Power: 0
date/time

thanks for that yes it did exactly what I wanted it to do, incldientally although you are probably verk knowledgeable in the area of coldfusion how did you know about tis command createODBCDate and in what situations to use it?
Ta

Reply With Quote
  #6  
Old April 21st, 2004, 03:03 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,488 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 10 m 11 sec
Reputation Power: 42
The first place you should look when you want to do something is the CFML reference, for tags and functions. If you can't find anything, try the developers exchange for a custom tag or CFC, and then look at www.cflib.org for a user-defined function. If nothing is there either, then you'll have to build something yourself.

Over time you get to know the available functions, just as it is when learning any language. createODBCDate() is used when you need a date in the ODBC date format, usually for interacting with databases.

Reply With Quote
  #7  
Old April 21st, 2004, 03:14 PM
mike_uk mike_uk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 9 mike_uk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m
Reputation Power: 0
CFML Reference

Thanks for the advise, the page contains very small text though, quite hard to read if I'm honest

Reply With Quote
  #8  
Old April 21st, 2004, 03:18 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,488 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 10 m 11 sec
Reputation Power: 42
Yes, the text is small. Just overlook that and search through the library to find UDF's that you might find useful. Aside from the small text cflib is very useful.

Reply With Quote
  #9  
Old April 21st, 2004, 03:33 PM
mike_uk mike_uk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 9 mike_uk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m
Reputation Power: 0
CFIF continued

Incidentally if I decided to use the BETWEEN statement e.g. WHERE OrderDate BETWEEN 1/1/2004 AND 31/12/2004 then could i also use createODBCDate() or a similar command that lets you search between date values etc etc?

Reply With Quote
  #10  
Old April 21st, 2004, 03:45 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,488 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 10 m 11 sec
Reputation Power: 42
Yes. The CF functions are processed BEFORE the statement gets forwareded to the RDBMS. So by the time the database gets the statement, the functions have already been substituted for time stamps.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Retreiving date information from tables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway