I was trying to query the duration of a WWE wrestler in the matches which he won and here I have successfully retrieved the data:

正规365体育投注I would like to remove those zeros and I tried the following piece of code:

strftime(%H:%M:%S, R1.time_in_match)

which doesn't work and give the following error:

 ': near "%": syntax error 

The data I imported were from a data frame which stores the time as time object and put them into the database as type DATETIME. The typeof function used on the "time_in_match" field returned type TEXT.

I was wondering if there is any way to format the time.


  • 1
    select strftime('%H:%M:%S', R1.time_in_match) you missed the single quotes. – forpas May 23 at 23:24

正规365体育投注SQLite provides 2 functions for this case:

strftime('%H:%M:%S', R1.time_in_match)

and simpler:



The time() function returns the time as HH:MM:SS

(from )

See the .

| improve this answer | |

正规365体育投注Your expression works as intended if you surround the format specifier with single quotes:

strftime('%H:%M:%S', time_in_match)

正规365体育投注You could also just use string functions here:

substr(time_in_match, 1, 8)

| improve this answer | |
  • Thanks, the first one doesn't work well. The second one is fine. – Harry1024 May 24 at 7:59
  • @Harry1024: the first one failed because I wrongly added single quotes around the identifier... fixed. – GMB May 24 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy正规365体育投注

Not the answer you're looking for? Browse other questions tagged or ask your own question.