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:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old February 25th, 2005, 10:57 AM
jdang jdang is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: OC, CA
Posts: 49 jdang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 15 m
Reputation Power: 4
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>

Reply With Quote
  #2  
Old February 25th, 2005, 11:22 AM
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
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

Reply With Quote
  #3  
Old February 25th, 2005, 11:26 AM
jdang jdang is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: OC, CA
Posts: 49 jdang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 15 m
Reputation Power: 4
Hi Kiteless

the error is, the condition where birthday.month = currentmonth does not get applied, it's just like empty codes

Reply With Quote
  #4  
Old February 25th, 2005, 11:48 AM
jdang jdang is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: OC, CA
Posts: 49 jdang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 15 m
Reputation Power: 4
it works now hehehe

Reply With Quote
  #5  
Old February 25th, 2005, 03:19 PM
Panther893's Avatar
Panther893 Panther893 is offline
MostarDesigns.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Posts: 808 Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 18 h 16 m 55 sec
Reputation Power: 56
Send a message via MSN to Panther893
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.

Reply With Quote
  #6  
Old February 25th, 2005, 08:13 PM
jdang jdang is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: OC, CA
Posts: 49 jdang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 15 m
Reputation Power: 4
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?

Reply With Quote
  #7  
Old February 26th, 2005, 02:42 AM
Panther893's Avatar
Panther893 Panther893 is offline
MostarDesigns.com
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Posts: 808 Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level)Panther893 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 18 h 16 m 55 sec
Reputation Power: 56
Send a message via MSN to Panther893
well isnt that what you are trieing to do??

Reply With Quote
  #8  
Old February 26th, 2005, 06:25 PM
r937's Avatar
r937 r937 is online now
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,344 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 8 h 27 m 14 sec
Reputation Power: 891
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>
__________________
r937.com | rudy.ca

Last edited by r937 : February 26th, 2005 at 06:27 PM.

Reply With Quote
  #9  
Old March 2nd, 2005, 08:02 PM
jdang jdang is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: OC, CA
Posts: 49 jdang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 15 m
Reputation Power: 4
Quote:
Originally Posted by Panther893
well isnt that what you are trieing to do??


naw, you misread my code, I checked month then day

Reply With Quote
  #10  
Old March 2nd, 2005, 08:03 PM
jdang jdang is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: OC, CA
Posts: 49 jdang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 15 m
Reputation Power: 4
Quote:
Originally Posted by r937
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>


wow, that is so much shorter and less confusing, thanks for the tip

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > CF/Access Date - Birthday query


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 4 hosted by Hostway