I am trying to build an app where I have a table with all post-dated cheques(PDC). I am unsuccessfully trying to pull out a list of all the PDC which are already due.
The logic is get today’s date and compare with the cheque date. If it is the current date or the past date, list it. Any pointers in the right direction would be much appreciated.
Could you provide more information?
Which DB are you using? MySQL?
In which format do you save dates?
Date Format: Date
[sql]CREATE TABLE IF NOT EXISTS
id smallint(5) NOT NULL,
bank_id tinyint(3) unsigned NOT NULL,
amount mediumint( unsigned NOT NULL,
master_property_id smallint(5) unsigned NOT NULL,
date date NOT NULL,
status tinyint(3) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=74 ;[/sql]
Thanks for the reply. I am ok with the MySQL part. What I am looking for is the Yii2 part. For instance:
$landlordCheque = ChequeLandlord::find()->where(['<=','date', NOW()])->orderBy('date')->all();
does not work. So I looking for the Yii2 format.
Thanks for the help. I think I figured it out. I used yii\db\Expression and could get the now() function.