12.02.2021, 12:14
Date/time is stored as UNIX timestamp. Check for month number wrap is not needed, it is handled by the os.time() automatically.
Keep in mind that alerts are deleted automatically, make sure that you've set the limit correctly in Utilities > General configuration.
Code:
date = os.date('*t')
date.day, date.hour, date.min, date.sec = 1, 0, 0, 0
ts_end = os.time(date)
date.month = date.month - 1
ts_start = os.time(date)
alerts_table = db:getall('SELECT * FROM alerts where alerttime BETWEEN ? AND ? ORDER BY id DESC', ts_start, ts_end)