Tags
MySQL
Asked 2 years ago
20 Apr 2022
Views 405
jagdish

jagdish posted

MySQL : how to get yesterday date by function

how to show a record that had the date of yesterday or update date of yesterday in the date type field


select where `datefield`=subtract(date(),1)


can I subtract normally from the current date by subtract function

or can i use like this

select where `datefield`=date()-1

can i do date()-1 like this

I get errors for all above practice

show me path
jaman

jaman
answered Apr 20 '22 00:00

in MySQL , you can use subdate() which subtract days from the given date
curdate() is the function where it return current date
so subdate(curdate(),1) will give you yesterday 's date

select * from tablename where `date`=subdate(curdate(),1)

Post Answer