[UPHPU] select records with date
Wade Preston Shearer
wadeshearer.lists at me.com
Thu Jan 28 11:12:50 MST 2010
On 28 Jan 2010, at 6:42, Justin Giboney wrote:
> See if this logic helps you, it will get you close, you may need to
> refine it
>
> basically it finds out how many years it has been since the person
> signed up, subtracts 3 from it, then adds that number to the sign up
> date and gets all records after that new date
>
> SELECT * FROM Users u, User_Actions ua
> WHERE u.id = ua.user_id
> AND ua.date >= ADDDATE(u.sign_up_date, INTERVAL (YEAR(NOW()) -
> YEAR(u.sign_up_date)) - 3) YEAR)
My client just changed the requirements slightly. I tried massaging
your suggested code to meet the new requirements but couldn't get it
to work. Here is the new logic:
select all user actions with completed date after most recent tri-
annual program anniversary
So, if the program started on 1 Aug 2000, then the query should return
all actions completed after 1 Aug 2009. Does that make sense?
1 Aug 2000 = program start
31 July 2003 = first anniversary
31 July 2006 = second anniversary
31 July 2009 = third and most recent anniversary
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3392 bytes
Desc: not available
Url : http://uphpu.org/pipermail/uphpu/attachments/20100128/dd818a6b/attachment.bin
More information about the UPHPU
mailing list