#compare string with date - eloquent ORM

10 messages · Page 1 of 1 (latest)

dull tartan
#

I think you asked this before, didn't you? There is a whereMonth and whereYear you can use.

icy swallow
dull tartan
#

So the field in the database is a text field and not a date field?

icy swallow
#

it looks like this ... where('2022-11' string, '2022-11' Date)

dull tartan
#

That is mes_ano in the DB?

icy swallow
#

On the ceiling table yes. Because I only need the month and year

icy swallow
dull tartan
#

That is going to make things tough for comparison, you should really be using a date field if you want to make datetime comparisons.

#

You might be able to cast it to a date using DB::raw, but it is going to be very slow.

icy swallow
#

How do I save only the month and year in DB?