On May 15, 2011, at 9:24 PM, Igor Tandetnik wrote:

> Mr. Puneet Kishor <punk.k...@gmail.com> wrote:
>> I am trying to get time stamps to be reported as '10:33 AM' and '1:27 PM' 
>> instead of '10:33' or '13:27'. I don't see any
>> formatting options to return the time in 12-hour format with AM/PM suffixed. 
>> Am I missing something, or do I have to roll my own? 
> 
> You are not missing anything. You'll have to roll your own.

Assuming 't' is a DATETIME column, the following seems work --

CASE
        WHEN CAST(strftime('%H', t, 'localtime') AS INTEGER) = 12 
                THEN strftime('%H:%M', t, 'localtime') || ' PM'  
        WHEN CAST(strftime('%H', t, 'localtime') AS INTEGER) > 12 
                THEN strftime('%H:%M', t, '-12 Hours', 'localtime') || ' PM' 
        ELSE strftime('%H:%M', t, 'localtime') || ' AM' 
END

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to