Reputation: 65
Using SQLite.
ltrim(ltrim(substr(tablename.time, 11),'0123456789'),'-') as main_time
I have the above trim
function which removes the first 11 characters from my string below.
2013-10-28 09:29:57.987 -- Original String.
09:29:57.987 -- New String.
However I'd still like to remove the last four characters from the end of the string, turning it into the below:
09:29:57
Upvotes: 5
Views: 11764
Reputation: 180020
To extract the time from such a string, just use the time function:
time(tablename.time)
Upvotes: 2
Reputation: 11151
Use LENGTH
:
SUBSTR(your_string, 1,LENGTH(your_string)-4)
However, in your case is just specify fixed positions:
SUBSTR(tablename.time, 12, 8)
Upvotes: 11