Solved

check ur birthday

Posted on 2001-06-29
12
281 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
  • 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
 
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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 50 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now