t-sqlmicrosoft-query

Microsoft Query TO_CHAR date


I'm trying to write sql select in Excel using Microsoft Query. the problem is it produces error when trying to execute to_char(date, 'mm-dd-yyyy') ; I tried all the possible variations: to_char(date, mm-dd-yyyy) , to_char(date, "mm-dd-yyyy") , to_char(date, 'mm-dd-yyyy') . Does anyone know symbols do I have to use to put the date format in??


Solution

  • to_char is not a part of T-SQL, it's a part of PL/SQL.
    The closest T-SQL equivalent is format, available from SQL-Server version 2012, and according to my current search it's also available in MS query.

    So instead of to_char(date, 'mm-dd-yyyy') use format(date, 'MM-dd-yyyy')