Pergunta

I appologize for asking this question, but i have searched and kind find anything specific to my needs. I have worked with it but can not seem to make ends meet.

I have a column SrcFileName (VarChar(100))

It is populated with filenames (i.e. AB20120928.143815458.txt) The AB does not change and the extension (.TXT) does not change.

I am trying to convert that SrcFileName to a DateTime value. This is a GMT timestamp.

str_to_date(Date_Field,'AB%YYYY%MM%DD.%HH%MM%SS.txt') Does not work, I believe I need to use Str_to_Date in conjunction with Convert().

Any assistance Appreciated!

Foi útil?

Solução

This should do it, just use SUBSTR to get the correct part of the string to parse and use STR_TO_DATE on that;

SELECT STR_TO_DATE(SUBSTR(SrcFileName,3,15), '%Y%m%d.%H%i%s') FROM TableA;
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top