Dinny Paul Dinny Paul - 1 month ago 4
MySQL Question

how to filter a select statement in mysql for a particular time period without using now()

I have tried to filter records but with the use of now function as given below

select * from table where date>= DATE_SUB( NOW( ) ,INTERVAL 90 DAY )


What I need is a select statement that can filter its records for a week or month from the current date but without using
NOW()
function

Answer

if you are using java you could make use of the following code

String timeStamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());

or you could use curdate() of mysql