0

I got a number in a table, which I want to use for the DATE_ADD function in MySQL.

So something like this:

SELECT DATE_ADD('2011-01-02', '+INTERVAL some_table.column DAY') AS newdate FROM some_table 

This will however not work, as MySQL will not understand some_table.column is a column with a value etc. Any help please?

1 Answer 1

2

Don't use quotes:

SELECT DATE_ADD('2011-01-02', INTERVAL some_table.column) AS newdate FROM some_table 
Sign up to request clarification or add additional context in comments.

2 Comments

I'm trying to do this more specifically: SELECT DATE_ADD('2011-01-02', +INTERVAL column DAY) AS newdate FROM table. It gives me SQL error.
There shouldn't be a '+' in that statement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.