Getting Uptime with SQL Report

4/26/2018 2546 Contributors

There are a couple of ways to get a computer's Uptime with an SQL Report.

The boot time is stored for each computer, so it's a matter of finding the difference between then and the current time. There are two ways to do it in SQLite. One method will give you seconds and the other will give you fractions of days. From there some simple math can get you hours or minutes.

Here are some examples:

    strftime('%s', 'now') - strftime('%s', BootTime) as Seconds, 
    (strftime('%s', 'now') - strftime('%s', BootTime)) / 3600 as Hours1, 
    julianday('now') - julianday(BootTime) as Days, 
    (julianday('now') - julianday(BootTime)) * 24 as Hours2 
from Computers;