views:

44

answers:

2

Hi

I feel stupid, but I can't get a TIMESTAMP column to be shown in human understandable way in a SELECT.

I could do that in MySQL, not in sqlite3.

Could someone show me an example please?

Thanks

+1  A: 

Here an example:

SELECT strftime('%Y', datetime(birthday_field, 'unixepoch', 'localtime'))
AS birthday_year 
FROM birthdays;

The following is a complete list of valid strftime() substitutions:

%d      day of month: 00
%f      fractional seconds: SS.SSS
%H      hour: 00-24
%j      day of year: 001-366
%J      Julian day number
%m      month: 01-12
%M      minute: 00-59
%s      seconds since 1970-01-01
%S      seconds: 00-59
%w      day of week 0-6 with sunday==0
%W      week of year: 00-53
%Y      year: 0000-9999
%%      % 
systempuntoout
accepted, for putting the effort into the answer, although you got inspired by munissor. He got only upvoted.Thanks
Flavius
+1  A: 

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

munissor
**(,'** <-- where should it get the column from ??
Flavius
ups..the editor removed some text from the answer. Fixed!
munissor