sqldateformattingingres

sql show date time as dd/mm/yy hh:mm:ss without using CONVERT(VARCHAR(10)


I am using Ingres Db which is old and cant do much, I need to show datetime in specific format as

dd-mm-yyyy hh:mm:ss

DB retunrn me it as

01.02.2018 14:43:53

it is NOT SQL server so I CANNOT use CONVERT(VARCHAR(10) Is there a way to convert it to format i need ?


Solution

  • to show it as dd-mm-yyyy hh:mm:ss you have to do next

    SELECT Varchar(Date_part('day', date('now')))
           + '-'
           + Varchar(Date_part('month', date('now')))
           + '-'
           + Varchar(Date_part('year', date('now')))
           + ' '
           + Varchar(Date_part('hour', date('now')))
           + ':'
           + Varchar(Date_part('minute', date('now')))
           + ':'
           + Varchar(Date_part('second', date('now')));