TheRealMatze Active Member Licensed User Dec 7, 2021 #1 Hi, i have a problem getting a accurate datediff. I need a 1-second-resolution beginning on the 1st of january 2020 00:00:00 UTC. I was thinking the easiest way is using sqlight... B4X: Copy Sub timestamp() As Int Dim r As ResultSet=sql1.ExecQuery("select (julianday('now') - julianday('2020-01-01 00:00:00')) * 86400 as x") r.Position=0 Return r.GetString("x") End Sub On my pc in sqlight cli it works as i expected, in b4a i have only every 100 seconds a change... So it jumps from 61.040.600 to 61.040.700 instead of 61.040.601. i need a compatible solution for android and ios, has anyone a idea? Thanks Matze Last edited: Dec 7, 2021
Hi, i have a problem getting a accurate datediff. I need a 1-second-resolution beginning on the 1st of january 2020 00:00:00 UTC. I was thinking the easiest way is using sqlight... B4X: Copy Sub timestamp() As Int Dim r As ResultSet=sql1.ExecQuery("select (julianday('now') - julianday('2020-01-01 00:00:00')) * 86400 as x") r.Position=0 Return r.GetString("x") End Sub On my pc in sqlight cli it works as i expected, in b4a i have only every 100 seconds a change... So it jumps from 61.040.600 to 61.040.700 instead of 61.040.601. i need a compatible solution for android and ios, has anyone a idea? Thanks Matze
M Mahares Expert Licensed User Longtime User Dec 7, 2021 #2 TheRealMatze said: i have a problem getting a accurate datediff. I need a 1-second-resolution Click to expand... Try this one: Code: Copy Dim r As ResultSet=SQL.ExecQuery("Select (strftime('%s','now') - strftime('%s','2020-01-01 00:00:00')) as x") instead of: Code: Copy Dim r As ResultSet=sql1.ExecQuery("select (julianday('now') - julianday('2020-01-01 00:00:00')) * 86400 as x") Upvote 2
TheRealMatze said: i have a problem getting a accurate datediff. I need a 1-second-resolution Click to expand... Try this one: Code: Copy Dim r As ResultSet=SQL.ExecQuery("Select (strftime('%s','now') - strftime('%s','2020-01-01 00:00:00')) as x") instead of: Code: Copy Dim r As ResultSet=sql1.ExecQuery("select (julianday('now') - julianday('2020-01-01 00:00:00')) * 86400 as x")