Hi,
I have already the date difference between 'Start date' and 'End date' but I also want to calculate the date 10 days after the "End date" in a table.
The first line is OK but when I add the second one the result in column 'End date plus 2 weeks' says Invalid date. It also duplicates the rows.
SELECT *, DATEDIFF(day,'Start date','End date')+ " days" as 'Duration' from T1 UNION
SELECT *, DATE_ADD(DAY, 10, "End date") AS 'End date plus 2 weeks' from T1
How can I fix this?
Thanks
Sofie
Hi Sofie,
Please, try this query:
SELECT *, DATEDIFF(day,'End date','Start date')+ " days" as 'Duration', DATE_ADD(DAY, 10, 'End date') AS 'End date plus 2 weeks' from T1
Hi,
Thank you for your answer. Almost there ...
The duplicated row disappeared, but now 'Duration' is negative date and 'End date plus 2 weeks' still invalid Date.
I'm a complete beginner so really appreciate your help !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I reproduced your usw case and this query works for me:
SELECT *, DATEDIFF(day,'Start date','End date')+ " days" as 'Duration',
FORMATDATE('End date' + "240h") AS 'End date plus 2 weeks' FROM T1
Also, you can use "10d" instead of "240h", but make sure 1 day is set to 24 hours in the settings (by default it is set to 8 working hours).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.