?
Solved

check ur birthday

Posted on 2001-06-29
12
Medium Priority
?
289 Views
Last Modified: 2013-12-24
i need to implement a function which could check for customer birthday
let say i store the DOB in date format, dd-mmm-yyyy in database

i plan to use query to extract the birthday within two week, so
the query will be something like this:

<cfquery name="DOBcheck" datasource="profile" dbtype="ODBC">
select *
from Cust_info
where cust_dob-now() <= 14 AND cust_dob-now()> 0
order by cust_dob
</cfquery>

but the problem is the comparation is include "year"
if i just wanto compare using day and month,
like "1 Jul" display, since it is within condition range)

how the condition *** wil look like?
0
Comment
Question by:KKrui
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +2
12 Comments
 
LVL 6

Expert Comment

by:dash420
ID: 6237661
Hi
instead of using coldfusion function now(), use the sysdate of oracle if u are using oracle. it will solve ur problem.

<cfquery name="DOBcheck" datasource="profile" dbtype="ODBC">
select *
from Cust_info
where (cust_dob- to_date(sysdate,'dd-mon-yyyy') <= 14 )AND (cust_dob- to_date(sysdate,'dd-mon-yyyy') > 0)
order by cust_dob
</cfquery>

otherwise use dateformat of coldfusion before cust_dob variable. it will definitly work.

0
 

Author Comment

by:KKrui
ID: 6239999
no, if just directly deduct from the date, it will definately not work.
just like if someone birthday was on 01-jul-1975
if compare with today's date, which is 30-jun-2001,
the different of time will be more than 14 days.

i just want it to compare the day's and month only, to display
those birthday which will be coming in two weeks time.
0
 

Author Comment

by:KKrui
ID: 6244256
can anyone has idea on it??
0
Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

 
LVL 2

Expert Comment

by:jamathon
ID: 6245843
I think you need the query to return all customers, you can then loop through the resultset and perform string manipulation to change their DOB to their birthday this year and then use datediff.

If there are a lot of records you may be better to schedule the task to run when the server is quiet.
0
 

Expert Comment

by:Paulmc
ID: 6246628
Have you tried using DateDiff to get the value you are looking for?

WHERE
#Abs(DateDiff('d', DateFormat("#cust_dob#","dd"), day(Now())))# <= 14
AND
#Abs(DateDiff('m', cust_dob, Now()))# > 0


Regards,

Paul.
0
 

Author Comment

by:KKrui
ID: 6247626
hi, jamathon. can u show me an example?
0
 
LVL 6

Expert Comment

by:dash420
ID: 6247728
Hi KKrui

sorry for this delay. Actually u can't do directly through query rather u can check this through coldfusion.

code is like this


<cfquery name="qrytest" datasource="ebdb" debug="Yes">
    select date1 from temp
</cfquery>

<cfoutput query="qrytest">
   <cfif #datediff('d',day(Now()),dateformat(date1,"dd")) #lte 14
       and #evaluate( month(Now()) - month(date1) ) #  eq 0>
      #date1#</cfif>
</cfoutput>

it will print only the dateof birth 14 days beyonds current date.    

check with this code it will  work.
0
 
LVL 6

Expert Comment

by:dash420
ID: 6248081
Hi KKrui

sorry for this delay. Actually u can't do directly through query rather u can check this through coldfusion.

code is like this


<cfquery name="qrytest" datasource="ebdb" debug="Yes">
    select date1 from temp
</cfquery>

<cfoutput query="qrytest">
   <cfif #datediff('d',day(Now()),dateformat(date1,"dd")) #lte 14
       and #evaluate( month(Now()) - month(date1) ) #  eq 0>
      #date1#</cfif>
</cfoutput>

it will print only the dateof birth 14 days beyonds current date.    

check with this code it will  work.
0
 
LVL 2

Accepted Solution

by:
jamathon earned 200 total points
ID: 6249009
hi, code should be something like this

using dd-mm-yyyy


<cfquery name="DOBcheck" datasource="profile" dbtype="ODBC">
select *
from Cust_info
order by cust_dob
</cfquery>



<cfloop query="DOBcheck">
<cfset birth_day=left(cust_dob,2)>
<cfset birth_month=left(right(cust_dob,7),2)>
<cfset this_year=dateformat(now(),'yyyy')
<cfset this_birthday=createdate(this_year,birth_month,birth_day)>
<cfif datediff('d',now(),this_birthday) eq 14>
put your condition here to add to list or array
</cfif>
</cfloop>


Probably best scheduled as an overnight task
0
 
LVL 2

Expert Comment

by:jamathon
ID: 6250705
I think you may find a flaw in dash420's code

It will only work when the current date and the database date are in the same month.

Also I neglected to close a tag in my code

Cheers
0
 
LVL 6

Expert Comment

by:dash420
ID: 6251202
I forgot to think of that case when sysdate will end of the month so please change the last condition.

condition code is


<cfoutput query="qrytest">
<cfif #datediff('d',day(Now()),dateformat(date1,"dd"))#    lte 14
       and #evaluate( month(Now()) - month(date1) ) #   lte 1>
 
<!---put ur code here--->
/cfif>
</cfoutput>    
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6338438
KKrui:

You have asked 11 questions within Experts Exchange and finalized (graded/awarded) zero of them.

_________________________________________________________

It's time to clean up this topic area and that means taking care of this question. Your options at this point are:
 
1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.
 
2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.
 
3.  Ask Community Support to help split points between participating experts.  Just comment here with details.
 
4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.
 
If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.  We also request that you review any other open questions you might have and update/close them.  Display all your question history from your Member Profile to view details.
 
PLEASE DO NOT AWARD THE POINTS TO ME.
 
____________________________________________
 
 
 
Hi Experts:
 
In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.
 
Experts, please do not add further "answer" information to this question.  I will be back in about one week to finalize this question.
 
Thank you everyone.
 
Moondancer :)
Community Support Moderator @ Experts Exchange
 
P.S.  Engineering has been advised about the error in the comment date/time sort order.  REGARDING POINTS and more see this link please.  Easy questions begin at a recommended 50 points.  You can quickly and easily change the value of your open questions:  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp  
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question