Skip to content

Instantly share code, notes, and snippets.

@theotherian
Last active August 29, 2015 14:08
Show Gist options
  • Save theotherian/0be39a4b303063751c85 to your computer and use it in GitHub Desktop.
Save theotherian/0be39a4b303063751c85 to your computer and use it in GitHub Desktop.
SQL for iPhone messages
select
case is_from_me when 0 then 'Other Person' else 'Me' end,
-- you may be wondering what the hell 'date + 978307200' is about
-- the iPhone stores dates as seconds past Jan 1st, 2001 rather than 1970
-- adding the 978307200 will 'move' your date up to the epoch, which allows sqllite to convert it for you
datetime(date + 978307200,'unixepoch', 'localtime'),
text
from
message
where
handle_id in (
select
ROWID
from
handle
where
id = '<phone number you care about as +1[area code][number]>'
)
;
PRAGMA table_info(handle);
SQL for iPhone messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment