'Convert datetime object to a SQL expression string
If database_expression is empty, the internal dttm
will be parsed as the string with the pattern that
the user inputted (python_date_format)
If database_expression is not empty, the internal dttm
will be parsed as the sql sentence for the database to convert'

def dttm_sql_literal(self, dttm):

    tf = (self.python_date_format or '%Y-%m-%d    %H:%M:%S.%f')
    if self.database_expression:
        return self.database_expression.format(dttm.strftime('%Y-%m-%d    %H:%M:%S'))
    elif (tf == 'epoch_s'):
        return str((dttm - datetime(1970, 1, 1)).total_seconds())
    elif (tf == 'epoch_ms'):
        return str(((dttm - datetime(1970, 1, 1)).total_seconds() * 1000.0))
    else:
        s = self.table.database.db_engine_spec.convert_dttm((self.type or ''), dttm)
        return (s or "'{}'".format(dttm.strftime(tf)))
