Krishna508
Krishna508

Reputation: 9

Updating FromDate and ToDate columns in table

I have a MySQL table in which I have two columns Fromdate and Todate. When ever I execute the stored procedure in MySQL, I want to update the fromdate and todate in the above table as next date.

For example

It should be updated to:

Upvotes: 0

Views: 54

Answers (2)

Ravi
Ravi

Reputation: 31417

Try this

Update yourtable set fromdate=DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00'),todate=DATE_FORMAT(NOW(),'%Y-%m-%d 23:59:59') where <<condition>>

Upvotes: 0

Shushil Bohara
Shushil Bohara

Reputation: 5656

TRY THIS: and you can do it with your own selected date as well

UPDATE test_table 
SET 
    from_date = DATE_FORMAT(NOW(),"%Y-%m-%d 00:00:00"),
    to_date = DATE_FORMAT(NOW(),"%Y-%m-%d 23:59:59")

and you add rest of conditions whatever you want to.

Upvotes: 1

Related Questions