Adobe Dreamweaver Forums



Last 10 THreads :         Dragging components (Last Post : hsfrey - Replies : 4 - Views : 5 )           »          Charts: Gap between Vertical Axis and the chart area (Last Post : flexisawesome - Replies : 0 - Views : 1 )           »          Pop up window using AS3 (Last Post : retsnomrev - Replies : 3 - Views : 4 )           »          can a combobox contain two different list seperated byvdivider ? (Last Post : v-Jay - Replies : 2 - Views : 6 )           »          Refreshing xml data in flex (Last Post : PiyushGiri01 - Replies : 2 - Views : 19 )           »          Integrating Captivate with ASP - SQL? (Last Post : bikturisint - Replies : 19 - Views : 131 )           »          Re: IPhone (Last Post : MiLSaN99 - Replies : 0 - Views : 1 )           »          Re: IPhone (Last Post : MiLSaN99 - Replies : 0 - Views : 1 )           »          Re: IPhone (Last Post : MiLSaN99 - Replies : 0 - Views : 1 )           »          Re: IPhone (Last Post : MiLSaN99 - Replies : 0 - Views : 1 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Cold Fusion > Getting Started
 
Tags:



Reply
  #1 (permalink)  
Old 12-01-2008, 11:15 PM
colohc
 
Posts: n/a
Diggs:
Default cfquery date help

Hi,

I am trying to create a cfquery that will search the renewaldate field and
will pull up records that will have the same month and year as the current
month and year.

Any suggestions on the best way to do this?

TIA



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-02-2008, 12:34 AM
Dan Bracuk
 
Posts: n/a
Diggs:
Default Re: cfquery date help

Your date field might appear like yyyy-mm-dd, but that's a display thing. I
don't use mysql but when I googled "mysql date functions" I found this.
http://www.w3schools.com/SQL/sql_dates.asp

Year and month functions did not appear, but curdate returns the current date.
That being the case, Cold fusion functions are probably a better way to go.

Use a combination of now(), year, month, and dateadd to get the 1st day of the
current month and the first day of the next month. Let's call those variables
date1 and date2.

They get used in your query like this

where renewal_date >= <cfqueryparam value="#date1#">
and renewal_date < <cfqueryparam value="#date2#">



Reply With Quote
  #3 (permalink)  
Old 12-02-2008, 04:33 AM
Azadi
 
Posts: n/a
Diggs:
Default Re: cfquery date help

mSQL has a whole array of built-in date functions you can use:

SELECT ..., your_date_column
FROM members
WHERE YEAR(your_date_column) = YEAR(NOW()) AND MONTH(your_date_column) =
MONTH(NOW())

note that all the functions above are MySQL functions, NOT cf functions,
so DO NOT use # around them.


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Reply With Quote


  #4 (permalink)  
Old 12-02-2008, 01:54 PM
colohc
 
Posts: n/a
Diggs:
Default Re: cfquery date help

Azadi, That worked great! Thank you

[q]Originally posted by: Newsgroup User
mSQL has a whole array of built-in date functions you can use:

SELECT ..., your_date_column
FROM members
WHERE YEAR(your_date_column) = YEAR(NOW()) AND MONTH(your_date_column) =
MONTH(NOW())

note that all the functions above are MySQL functions, NOT cf functions,
so DO NOT use # around them.


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
[/q]



Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 07:31 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk