Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Upcoming Birthdays - Number of Days from Today
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01152408
Message ID:
01152417
Views:
20
Sergey....

This code will not work if the Birtdate is Before the date range (Date to Date + 30) (this is due to overlapping the first of the year - if the date range goes over the 1st and the birtday of THIS year SHOULD have been in NEXT year, in the date range.

Here is the old code to see how it worked before....
	SELECT patient_master
	SET ORDER TO NAME
	GO TOP IN patient_master
	SCAN FOR !EMPTY(date_birth)
		DO CASE
		CASE MONTH(date_birth) < MONTH(DATE())
			lnYearModifier = 1
		CASE MONTH(date_birth) = MONTH(DATE())
			IF DAY(date_birth) < DAY(DATE())
				lnYearModifier = 1
			ELSE
				lnYearModifier = 0
			ENDIF
		OTHERWISE
			lnYearModifier = 0
		ENDCASE
		ldBirthday = CTOD(ALLTRIM(STR(MONTH(date_birth))) + "/" + ALLTRIM(STR(DAY(date_birth))) + "/" + ALLTRIM(STR(YEAR(DATE()) + lnYearModifier)))
		IF BETWEEN(ldBirthday,DATE(),DATE() + VAL(THISFORM.pgfReport.LabelsPage.cntOptions.txtInfo3.VALUE))
			APPEND BLANK IN mailinglabels
			REPLACE NAME WITH ALLTRIM(patient_master.first_name) + " " + ALLTRIM(patient_master.last_name), ;
				address1 WITH ALLTRIM(patient_master.address_1), ;
				address2 WITH ALLTRIM(patient_master.address_2), ;
				citystzip WITH ALLTRIM(patient_master.city) + ", " + ALLTRIM(patient_master.state) + "  " + ALLTRIM(patient_master.zip_code) IN mailinglabels
		ENDIF
	ENDSCAN
Maybe a UDF in the SQL Select that returns the modified Birtdate (using the code above as a guide), then in the WHERE clause using the Between statement...?

Thanks!

>Try
>SELECT * FROM mytable ;
>	WHERE DATE(YEAR(DATE()), MONTH(birthdate), DAY(birthdate)) BETWEEN DATE() AND DATE() + 30
>
>>
>>You guys have probably already figured this one out years ago.... but this is the first time I need this. I am converting some code over that works, but it uses SCAN/ENDSCAN and does NOT use SQL.
>>
>>Question.
>>
>>Given a table of patients with their birthdays in it. I wish to query the table to return the patients who have birthdays within TODAY's DATE and a given number of days in the future (say 30 days from today).
>>
>>Any straightfoward code that employs SQL? The code I am working on used SCAN and ENDSCAN to go through the patient table, figure out if the "birthday" needs correcting to today's year, or next years, and then that value is use in a BETWEEN statement to see if the "birthday" is between DATE() and DATE() + NUMBER OF DAYS IN THE FUTURE.
>>
Tommy Tillman A+ NetWork+ MCP
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform