Skip to content
Advertisement

How to cast this integer value to date in MySQL

i have airbnb data and i want to cast column last_reviews (which datatype is int) to date this is my sql code http://sqlfiddle.com/#!9/b5ea42/31

how do i cast int > date? or how do i create last_reviews column as datatype date?

Advertisement

Answer

The last_review date seems to be the number of days since 1900-01-01 so in MySQL you would:

SELECT '1900-01-01' + INTERVAL last_review DAY AS last_review_date
FROM ...

The result checks out for the sample data (which you should delete).

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement