catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.84k stars 1.15k forks source link

Using [<>] and [><] with portion of datetime #603

Closed nealoke closed 7 years ago

nealoke commented 7 years ago

I'm wondering if I could use the [<>] and [><] with only a part of the date. I would like to filter a column named birthday which contains the whole birthday date of a person. I need to retrieve only the people who have their birthday on a certain date (eg. filtering on month and day, not on year).

Is this possible with the current version?

Andrews54757 commented 7 years ago

https://www.w3schools.com/sql/sql_like.asp

@nealoke Use like to run a query using wildcards.

$Medoo->select('table',['birthday'],[
    'birthday[~]' => '%MM-DD'
]); // SELECT birthday FROM table WHERE birthday LIKE %MM-DD
nealoke commented 7 years ago

Thanks! I'll have a look at it as soon as I can :)