LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-11-2015, 07:10 PM   #1
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
thunderbird sqlite backup file. converting dates


hi, i have this sqlite backup file:
./.thunderbird/xycahv7k.default/calendar-data/local.sqlite

i can get this data:
Code:
sqlite> select title, event_start from cal_events where id = '21a690b7-ba53-43e5-9d85-8b3805bceef1';
title|event_start
mom's b-day|1332979200000000
how do i convert the event_start to mm/dd/yyyy (either in sql or bash).

this is the error i am getting:
Code:
[schneidz@hyper schneidz]$ date 1332979200000000
date: invalid date ‘1332979200000000’
 
Old 07-11-2015, 07:16 PM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Original Poster
Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
this is the command
Code:
[schneidz@hyper schneidz]$ date -u --date='@1348531200000000'
Tue Jul 26 00:00:00 UTC 42735222
[schneidz@hyper schneidz]$ date -u --date='@1348531200'
Tue Sep 25 00:00:00 UTC 2012
i had to remove the trailing 0s until i got the correct date.
 
Old 11-30-2015, 10:00 PM   #3
Kroggen
LQ Newbie
 
Registered: Nov 2015
Location: Brazil
Distribution: Ubuntu and Debian
Posts: 2

Rep: Reputation: Disabled
In SQLite you can use the datetime function:

SELECT datetime(1092941466, 'unixepoch');

will return the julian day number converted to a date in the "yyyy-mm-dd hh:mm:ss" format, in UTC.

To convert to localtime:

SELECT datetime(1092941466, 'unixepoch', 'localtime');

In your query:

select title, datetime(event_start, 'unixepoch') as ev_start from cal_events where id = '21a690b7-ba53-43e5-9d85-8b3805bceef1';
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Sqlite-Commander - A ncurses based tool to display the records and tables of a sqlite database LXer Syndicated Linux News 0 01-02-2011 08:11 AM
How to processing the log file within certain dates based on the file name shyork2001 Linux - General 1 04-08-2010 03:35 PM
SQLite database backup ddpicard Linux - Software 2 11-01-2004 06:54 PM
File Dates Rv5 Programming 5 09-07-2004 05:59 PM
Converting KMail's Maildir to Mozilla Thunderbird? amphibious Linux - Software 0 10-02-2003 09:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration