Results 1 to 5 of 5
Thread: quick date_sub question
Oct 23, 2001, 15:51 #1
- Join Date
- Sep 2000
- Ontario, Canada
- 0 Post(s)
- 0 Thread(s)
quick date_sub question
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.
SELECT agentname, signup,
IF((DATE_SUB(CURDATE(),signup <= INTERVAL 1 MONTH),1,0) AS new_customer
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 helpJason Dulberg