|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
CF/Access Date - Birthday query
Hi Everyone,
I tried searching but didn't find what I was looking for. Aniway, I'm trying to query from an Access DB to see who has a birthday today and here's what I did, but it doesnt seem to work right, I think the code for extracting month and days isn't correct, could somebody please fix it for me? thanks ![]() <cfset currentmonth = Month(Now())> <cfset currentday = day(Now())> <cfquery name="getbirthdays" datasource="employees"> select * from tblEmployees where birthday is not null </cfquery> </cfoutput> <cfoutput query="getbirthdays"> <cfif #MonthAsString(Month(birthday))# eq #currentmonth#> #firstname# #lastname# </cfif> none </cfoutput> |
|
#2
|
|||
|
|||
|
Showing the code doesn't help if you don't explain what the problem or error is.
__________________
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 |
|
#3
|
|||
|
|||
|
Hi Kiteless
the error is, the condition where birthday.month = currentmonth does not get applied, it's just like empty codes ![]() |
|
#4
|
|||
|
|||
|
it works now hehehe
![]() |
|
#5
|
||||
|
||||
|
why not just do it this way:
<cfquery name="birthdays" datasource="employees"> SELECT birthday, firstname, lastname FROM tblEmployees WHERE birthday = #dateFormat(now())# </cfquery> <cfoutput query="birthdays"> #firstname# #lastname# </cfoutput> i think that way is much simpler then what youre using, unless you have additional code that needs it to be that way. |
|
#6
|
|||
|
|||
|
Hi,
correct me if i'm wrong but if you use WHERE birthday = #dateFormat(now())# wouldn't that return only the users whose birthday is today? meaning they'd be born today? ![]() |
|
#7
|
||||
|
||||
|
well isnt that what you are trieing to do??
|
|
#8
|
||||
|
||||
|
no CFSETs, no local variables, no fuss, no muss, and most importantly, you don't return the entire employee table just to CFIF them in in the CFOUTPUT loop to find out who has a birthday, you just return only those employees who do --
Code:
<cfquery name="getbirthdays" datasource="employees">
select *
from tblEmployees
where format(birthday,"mmdd")
= format(date(),"mmdd")
</cfquery>
Last edited by r937 : February 26th, 2005 at 06:27 PM. |
|
#9
|
|||
|
|||
|
Quote:
naw, you misread my code, I checked month then day ![]() |
|
#10
|
|||
|
|||
|
Quote:
wow, that is so much shorter and less confusing, thanks for the tip ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > CF/Access Date - Birthday query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|