简体   繁体   中英

Parse on SQL query

from an old datatable (.dbf file) in a non formated column I got the a time value with 2 extra alphabetic letters. ejpl: 12:34:56AB = HH:mm:ssAB. The 2 letters stand for some userindefication(users inicials). How can I separate the time with this extra 2 letters in 2 different colums?

In SQL Server you can use right() and left() :

select right(timeval, 2) as initials,
       left(timeval, 8) as time

In fact, these functions are available in most databases. And, all databases have similar functionality even if the functions are slightly different.

Pure Standard SQL:

select substring(col from 1 for 8) as timepart,
       substring(col from 9) as initials

In case there are no initials this will return an empty string, Gordon's will return the seconds instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM