|
|
Question : how to convert char(14) field to dd/mm/yyyy hh:mm:ss
|
|
How to convert char field of length 14 to the format dd/mm/yyyy hh:mm:ss in sybase. Please help me some one.
Thanks
|
Answer : how to convert char(14) field to dd/mm/yyyy hh:mm:ss
|
|
Ok, i'm using ASA that use aliases different than ASE. Try this SQL, is simpler and shuold be good:
select DATEADD( Second, (DATEDIFF( Second , CONVERT(DATETIME, SUBSTR(YourField, 1, 4) + '-' + SUBSTR(YourField, 5, 2) + '-' + SUBSTR(YourField, 7, 2) + ' ' + SUBSTR(YourField, 9, 2) + ':' + SUBSTR(YourField, 11, 2) + ':' + SUBSTR(YourField, 13, 2)), CONVERT(DATETIME, SUBSTR(YourField2, 1, 4) + '-' + SUBSTR(YourField2, 5, 2) + '-' + SUBSTR(YourField2, 7, 2) + ' ' + SUBSTR(YourField2, 9, 2) + ':' + SUBSTR(YourField2, 11, 2) + ':' + SUBSTR(YourField2, 13, 2))) ) , DATE('1900-01-01'));
|
|
|
|
|