At the start of every month I'm running a script that outputs customer names and how much they owe per month. What I'm trying to do now is add a one time setup fee for each customer. So I was thinking of using mySQL's IF and DATE_SUB to determine whether or not the person signed up within the month and add the setup fee if they do.
Here's what I have but I don't think my logic is correct. I'm having trouble combining mySQL's IF and DATE_SUB together.
I based my query from code given herePHP Code:SELECT agentname, signup,
IF((DATE_SUB(CURDATE(),signup <= INTERVAL 1 MONTH),1,0) AS new_customer
FROM agents;
Am I on the right track here? Is an IF/DATE_SUB even appropriate for what I'm trying to do?
I'm assuming that $signup should be in TIMESTAMP(14) format - correct?
As always... thanks for any help![]()





Bookmarks