Delete data between two time points

33 views
Skip to first unread message

Neil S

unread,
Jan 11, 2020, 9:29:51 AM1/11/20
to weewx-user
I am trying to delete data between two time points as it is erroneous (I updated and for a short period the station type was reset to simulate).

The time points are 11/1/20 at 10:39:00 and 11:16:00 (so I think I have the right unixepoch timestamps)

I have worked out how to delete data that is older or newer than any one point but not between. In theory the following should work 

sqlite3 /var/lib/weewx/weewx.sdb
delete from archive where datetime(dateTime,'unixepoch','localtime') BETWEEN '1578739140' AND '1578741360';
.exit


but it doesnt and just appears to delete all data up to the last time stamp. All historic data seems to have been deleted (including all the NOAA data).

I have also tried 

sqlite3 /var/lib/weewx/weewx.sdb
delete from archive where (datetime(dateTime,'unixepoch','localtime')>1578739140) AND (datetime(dateTime,'unixepoch','localtime')<1578741360);
.exit


Strangely the database size seems to be the same though - so is it just a case of me panicking that I am loosing data and I need to wait for tables to be rebuilt?

TIA
Neil

Thomas Keffer

unread,
Jan 11, 2020, 9:46:36 AM1/11/20
to weewx-user
It's actually much simpler. The field 'dateTime' is already in unix epoch time. So, you want

  delete from archive where dateTime>1578739140 and dateTime<1578741360;

Then rebuild the daily summaries.

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/0f6dc72d-4366-4e63-922a-bde2275822b7%40googlegroups.com.

Neil S

unread,
Jan 11, 2020, 10:03:40 AM1/11/20
to weewx-user
Bingo!

Thank you for your help.

Neil
To unsubscribe from this group and stop receiving emails from it, send an email to weewx...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages