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:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 4th, 2005, 05:13 PM
funktion funktion is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 3 funktion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 17 sec
Reputation Power: 0
Automatic Query Updates

Hi

I am new to Coldfusion and need assistance writing a simple query. I am using Coldfusion/Sql to output dates from my calendar database. Right now I am updating my events weekly withing the calendar. So my query looks like this:

<cfquery name="calendar" datasource="">
SELECT * FROM calendar
Where months = 'April'
and dates > 4
and dates < 7
order by dates asc
</cfquery>

How would I be able to write a query that looks for the next value automatically and limits the number of results, instead of me having to punch in numbers manually every week?

Thanks for the help

Reply With Quote
  #2  
Old April 4th, 2005, 05:28 PM
bocmaxima's Avatar
bocmaxima bocmaxima is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2004
Location: Tucson, Sonora
Posts: 1,322 bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 17 h 46 m 5 sec
Reputation Power: 22
Send a message via AIM to bocmaxima
It would be easier if you had just the week in the year, which would just be #Week(Now())#, but try this:

<cfif DayOfWeek(Now()) EQ 1><cfset firstday = DateFormat(Now(),"d")>
<cfset lastday = DateAdd("d",6,Now())>
<cfelse><cfset firstday = DateAdd("d",(DayOfWeek(Now())-1)*-1),Now())>
<cfset lastday = DateAdd("d",(7-DayOfWeek(Now())),Now())>
</cfif>
<cfquery name="calendar" datasource="">
SELECT * FROM calendar
Where months = '#DateFormat(Now(),"mmmm")#'
and dates > #firstday#
and dates < #lastday#
order by dates asc
</cfquery>

Reply With Quote
  #3  
Old April 4th, 2005, 07:32 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 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 4 Days 10 h 8 m 55 sec
Reputation Power: 53
You can do this by replacing the hardcoded values with function calls, and you could use either CFML functions or functions specific to your RDBMS.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Automatic Query Updates


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


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





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