Fwd: [sqlite-forum] Convert datetime string to second since Epoch with millisecond precision

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: [sqlite-forum] Convert datetime string to second since Epoch with millisecond precision

Dominique Devienne
Reposting to the ML, maybe I'll have more luck there, than in the forum?
--DD

---------- Forwarded message ---------
From: ddevienne <[hidden email]>
Date: Tue, Mar 17, 2020 at 5:09 PM
Subject: [sqlite-forum] Convert datetime string to second since Epoch with
millisecond precision
To: <[hidden email]>


Forum post by ddevienne on 2020-03-17 16:09:17
https://sqlite.org/forum/forumpost/0d9c338ff1

Hi. Below does what I want, but surely there's a better way than parsing
the datetime 3 times? Because the below is ugly as hell. Thanks, --DD

```
C:\Users\ddevienne>sqlite3
SQLite version 3.28.0 2019-04-16 19:49:53
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> select
   ...>        cast(strftime('%s', '2016-06-13T09:36:34.123Z') as real) +
   ...>             strftime('%f', '2016-06-13T09:36:34.123Z') -
   ...>        cast(strftime('%S', '2016-06-13T09:36:34.123Z') as real)
   ...> ;
1465810594.123
sqlite>
```
--
Subscription info:
https://sqlite.org/forum/alerts/54F6DD420B31FA7F9F69F5498F1631F5E6D4B48CF97539FDEEF90F71733E90A9
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: [sqlite-forum] Convert datetime string to second since Epoch with millisecond precision

Keith Medcalf

select (strftime('%J', '2016-06-13T09:36:34.123Z') - 2440587.5) * 86400.0;
1465810594.123

--
The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.

>-----Original Message-----
>From: sqlite-users <[hidden email]> On
>Behalf Of Dominique Devienne
>Sent: Tuesday, 17 March, 2020 10:37
>To: General Discussion of SQLite Database <sqlite-
>[hidden email]>
>Subject: [sqlite] Fwd: [sqlite-forum] Convert datetime string to second
>since Epoch with millisecond precision
>
>Reposting to the ML, maybe I'll have more luck there, than in the forum?
>--DD
>
>---------- Forwarded message ---------
>From: ddevienne <[hidden email]>
>Date: Tue, Mar 17, 2020 at 5:09 PM
>Subject: [sqlite-forum] Convert datetime string to second since Epoch
>with
>millisecond precision
>To: <[hidden email]>
>
>
>Forum post by ddevienne on 2020-03-17 16:09:17
>https://sqlite.org/forum/forumpost/0d9c338ff1
>
>Hi. Below does what I want, but surely there's a better way than parsing
>the datetime 3 times? Because the below is ugly as hell. Thanks, --DD
>
>```
>C:\Users\ddevienne>sqlite3
>SQLite version 3.28.0 2019-04-16 19:49:53
>Enter ".help" for usage hints.
>Connected to a transient in-memory database.
>Use ".open FILENAME" to reopen on a persistent database.
>sqlite> select
>   ...>        cast(strftime('%s', '2016-06-13T09:36:34.123Z') as real) +
>   ...>             strftime('%f', '2016-06-13T09:36:34.123Z') -
>   ...>        cast(strftime('%S', '2016-06-13T09:36:34.123Z') as real)
>   ...> ;
>1465810594.123
>sqlite>
>```
>--
>Subscription info:
>https://sqlite.org/forum/alerts/54F6DD420B31FA7F9F69F5498F1631F5E6D4B48CF
>97539FDEEF90F71733E90A9
>_______________________________________________
>sqlite-users mailing list
>[hidden email]
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users