|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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> |
|
#3
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Automatic Query Updates |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|