Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySql: Date_add returns BLOB

i have the next query: select avHours, date_add('2010-01-20', Interval 2 DAY) from tbl_available order by avHours;

but it returns a blob field and not a date field. when i see the value in the blob field, it's the right date.

how can i fix this?

Thanks in advance!

like image 891
Nick Avatar asked Feb 17 '12 01:02

Nick


People also ask

Why date_ ADD() is used?

DATE_ADD() function in MySQL is used to add a specified time or date interval to a specified date and then return the date.

How to store only date in MySQL?

The default way to store a date in a MySQL database is by using DATE. The proper format of a DATE is: YYYY-MM-DD.


1 Answers

MySQL functions sometimes converts to BLOB. You can fix it if you will cast result to a DATE type yourself, for example -

SELECT DATE(DATE_ADD('2010-01-20', INTERVAL 2 DAY))

or

SELECT CAST(('2010-01-20' + INTERVAL 2 DAY) AS DATE)
like image 111
Devart Avatar answered Sep 27 '22 17:09

Devart