Yii2 Date Compare

Hi,

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.

Thanks.

Hi,

Could you provide more information?

Which DB are you using? MySQL?

In which format do you save dates?

Datetimte? Timestamp?

Regards

Database: MySQL

Date Format: Date

SQL Query:

[sql]CREATE TABLE IF NOT EXISTS cheque_landlord (

id smallint(5) NOT NULL,

bank_id tinyint(3) unsigned NOT NULL,

amount mediumint(8) 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]

Hey,

Already used google? ;)

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

https://www.google.de/search?q=mysql+date+older+current&oq=mysql+date+older+current

Regards

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.

Thanks for the help. I think I figured it out. I used yii\db\Expression and could get the now() function.