Jump to content

Select overdue record using DATE Type Column


SangrelX

Recommended Posts

Ok basic setup is

 

Table name = unit_data

I have a field  unit_paid_date colum type = DATE

 

unit_paid_date = 2011-03-02

thats yyyy-mm-dd

 

lets say for example the DueDate is the Second of every month

 

I need to select all records from unit_data that are PAST DUE

so if the last paid date is 2011-01-02

 

that record will pop up as PAST DUE

 

BUT if that paid date is say 2011-03-10 it will not be shown because the invoice was paid Ahead of due date

 

I had this almost working properly -- but can use any help you guys offer.

I was attempting to use mysql WHERE queries and do checks against paid_date but failed

 

Thanks

 

 

Link to comment
Share on other sites

you can use following query :-

You can modify month or day accordingly

 

SELECT *, concat(date_format(now(),"%Y"),"-",date_format(now(),"%m"),"-", "2") as dates FROM `todolist` WHERE `due_date` < concat(date_format(now(),"%Y"),"-",date_format(now(),"%m"),"-", "2")

 

Link to comment
Share on other sites

you can use following query :-

You can modify month or day accordingly

 

SELECT *, concat(date_format(now(),"%Y"),"-",date_format(now(),"%m"),"-", "2") as dates FROM `todolist` WHERE `due_date` < concat(date_format(now(),"%Y"),"-",date_format(now(),"%m"),"-", "2")

 

 

Here is the Select im using

 

SELECT *, concat(date_format(now(),"%Y"),"-",date_format(now(),"%m"),"-", $daydisp) as dates FROM $pm_units WHERE unit_paid_date < concat(date_format(now(),"%Y"),"-",date_format(now(),"%m"),"-", $daydisp)

 

 

 

I see where your going with this but it will not work. this is comparing the Date in the field unit_paid_date to the current Date with the Day being a variable which is the actual DAY each month its due

 

 

im lost  but then again ive been trying to learn how to do this for a while now

 

it should be simple

 

if the user pays his bill ahead of the due date it leaves him alone

if the users bill was paid say LAST month on the 2nd then it will be marked as late and the record shown

 

I had at one time it worked all execept say if the user paid his bill Ahead of time it still marked it as a late payment .. and i didnt fully comprehend why so i removed that code and now I dont remember what it was lol..

 

i hope someone understands my end goal here and can help me out

 

Thanks

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.