Skip to content
Advertisement

Timestamps and addition of weeks

My query requires me to find the number of people positive and their infectious periods which is plus and minus 2 weeks. In my query below I keep getting null in my 2 weeks Timestamp

select PersonID, f_name || ' ' || L_name as 'Citizen', Timestamp, datetime ('Timestamp', '+2 Weeks')
from person natural join Testing
where Results is 'Positive';

Timestamp is null

What is wrong with my equation and why won’t it add the 2 weeks in the next column?

In DB browser this is the format I have to use for datetime.

Schema Attached Schema

Advertisement

Answer

You can’t add weeks like that with the DATETIME() function.
Add 14 days:

datetime(Timestamp, '+14 days')

You can find here: Modifiers all the modifiers that you can use.
Also column names must not be inside single quotes.

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