mysql - SQLite and STRFTIME -
in sqlite database, have time field minutes, seconds, , centiseconds:
 00:01:100 i want select row max value in milliseconds , fount strftime function. i'm trying with:
  select max(strftime("%m:%s:%sss", field)) table; but doesn't works.
because isn't in list of allowed formats, have first edit it's supported.
then run strftime function
select max(strftime("%h:%m:%f", "00:" || substr(field,1,3) || replace(':','.',substr(field,4)))) table; this should not work
edit
so, update. why doesn't work:
strftime useful when have time in format , want convert format. 
you have item in non-supported format. (list of formats here). so, have saved in default text format.
so, need write query takes text converts correct format , compares it. kind of have write own maximization function, convert text max function can handle.
this done combination of substrings , casting. i've done in query below cast substrings integers, multiply them convert them seconds , add max. 
select time,max(cast(substr(time,1,2) integer)*60+cast(substr(time,4,2) integer )+cast(substr(time,7,3) integer)/100) t; here's example of running
Comments
Post a Comment