Jopekz
Jopekz

Reputation: 45

Update Date Part Only in Date Time SQL

I have a table that has a ReadingTimeStamp field (DateTime data type). As you can see in the picture. It has 2017-06-19 XX:XX:XX . I want to change only the date part (2017-06-19) to 2017-07-26 without affecting the time. Can someone help me with a query? I am using SQLite Studio. Please see attached file.

enter image description here

Upvotes: 0

Views: 95

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521073

SQLite dates are basically just stored as strings. You can try the following update:

UPDATE yourTable
SET ReadingTimeStamp = '2017-07-26 ' || SUBSTR(ReadingTimeStamp, 12, 8)
WHERE SUBSTR(ReadingTimeStamp, 1, 10) = '2017-06-19'

Upvotes: 3

Related Questions