Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Anniversary/birthday reminders
Message
From
06/04/2005 17:35:39
 
 
To
06/04/2005 16:25:32
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01001497
Message ID:
01002099
Views:
24
Hi Frank

Works for me. Appears to be logically correct. This might illuminate things.
m.tdstart = DATE(2004,12,1)
m.tdend = DATE(2005,2,1)

SELECT contractor, stdatefn,;
		IIF(EMPTY(stdatefn),{},DATE(YEAR(m.tdStart), MONTH(stdatefn), DAY(stdatefn))) as dt_start,;
		IIF(EMPTY(stdatefn),{},DATE(YEAR(m.tdStart), MONTH(stdatefn), DAY(stdatefn))) as dt_end,;
		MONTH(stdatefn) as mm, DAY(stdatefn) as dd ;
	FROM contsub ;
	INTO  CURSOR tSelect1 ;
	ORDER BY 5,6

SELECT contractor, stdatefn,;
		IIF(EMPTY(stdatefn),{},DATE(YEAR(m.tdStart), MONTH(stdatefn), DAY(stdatefn))) as dt_start,;
		IIF(EMPTY(stdatefn),{},DATE(YEAR(m.tdStart), MONTH(stdatefn), DAY(stdatefn))) as dt_end,;
		MONTH(stdatefn) as mm, DAY(stdatefn) as dd ;
	FROM contsub ;
	WHERE NOT EMPTY(stdatefn) AND ;
	      (DATE(YEAR(m.tdStart), MONTH(stdatefn), DAY(stdatefn)) >=m.tdstart OR ;
	       DATE(YEAR(m.tdEnd), MONTH(stdatefn), DAY(stdatefn)) <=m.tdend) ;
	INTO  CURSOR tSelect ;
	ORDER BY 5,6
>Geoff,
>
>I had tried it with an OR but that also didn't work with start and end dates from different years. I got it to work with a slightly more complex version which you can find in one of my other messages. That is apparently working.
>
>Thanks for your help.
>
>>Hi Frank
>>
>>The date check needs to be an OR not AND
>>
>>
	WHERE NOT EMPTY(dob) AND ;
>>	      (DATE(YEAR(m.tdStart), MONTH(dob), DAY(dob)) >=m.tdstart OR ;
>>	       DATE(YEAR(m.tdEnd), MONTH(dob), DAY(dob)) <=m.tdend ));
>>
>>
>>Geoff
>>
>>>Geoff,
>>>
>>>after getting around a blank date problem, I am not getting the logic right in this. It works well if the year of both start and end dates is the same. However if I have the start date set at 31st Dec 2004 and End date at 1st Jan 2005, I get no data coming out, whereas there are dates on both days.
>>>
>>>
>>>WHERE NOT EMPTY(dob) AND (DATE(YEAR(m.tdStart), MONTH(dob), DAY(dob)) >=m.tdstart ;
>>>   AND DATE(YEAR(m.tdEnd), MONTH(dob), DAY(dob)) <=m.tdend );
>>>
>>>
>>>Any ideas on how I need to embellish the logic to get it to work?
>>>
>>>
>>>
>>>>Hi Frank
>>>>
>>>>Because the start year and end year may be different you need to test your month and day against both ends seperately.
>>>>
>>>>Try this
>>>>
>>>>
>>>>m.d_start = DATE(2004,10,15)
>>>>m.d_end = DATE(2005,04,15)
>>>>
>>>>SELECT dob as dactivity, client_no, PADR("Birthday", 20) as cType;
>>>>	FROM c_clientlist;
>>>>	WHERE DATE(YEAR(m.d_start),MONTH(dob),DAY(dob)) >= m.d_start AND ;
>>>>			DATE(YEAR(m.d_end),MONTH(dob),DAY(dob)) <= m.d_end
>>>>
>>>>
>>>>Geoff
>>>>
>>>>>Hi,
>>>>>
>>>>>I've gone brain dead :(
>>>>>
>>>>>I have some SQL code:
>>>>>
>>>>>
>>>>>SELECT dob as dactivity, client_no, PADR("Birthday", 20) as cType;
>>>>>	FROM c_clientlist;
>>>>>	WHERE DAY(dob) = DAY(DATE()) AND MONTH(dob) = MONTH(DATE())
>>>>>
>>>>>
>>>>>which will give me anybody who was born on the current day.
>>>>>
>>>>>Say I wanted to allow the user to enter a starting date and an ending date and then I will pull out all people who have birthdays falling within that range.
>>>>>
>>>>>How do I convert this to work on a range of dates?
May all your weeds be wildflowers
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform