Re: [sqlite] time in AM/PM?

2011-05-16 Thread Mr. Puneet Kishor

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

> Mr. Puneet Kishor  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


Re: [sqlite] time in AM/PM?

2011-05-15 Thread Igor Tandetnik
Mr. Puneet Kishor  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.
-- 
Igor Tandetnik

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


[sqlite] time in AM/PM?

2011-05-15 Thread Mr. Puneet Kishor
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?

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