code: def convert_dttm(
      cls,
      target_type: str,
      dttm: datetime,
      db_extra: Optional[dict[str, Any]] = None,
  ) -> Optional[str]:
      sqla_type = cls.get_sqla_column_type(target_type)
  
      if isinstance(sqla_type, types.Date):
          return f"CONVERT(DATE, '{dttm.date().isoformat()}', 23)"
      if isinstance(sqla_type, SMALLDATETIME):
          datetime_formatted = dttm.isoformat(
              sep=" ", timespec="seconds"
          )
          return (
              f"""CONVERT(SMALLDATETIME, '{datetime_formatted}', 20)"""
          )
      if isinstance(sqla_type, types.DateTime):
          datetime_formatted = dttm.isoformat(timespec="milliseconds")
          return f"""CONVERT(DATETIME, '{datetime_formatted}', 126)"""
      return None
  
file_path: superset/superset/db_engine_specs/mssql.py
imports: import logging
  import re
  from datetime import datetime
  from re import Pattern
  from typing import Any, Optional
  from flask_babel import gettext
  from sqlalchemy import types
  from sqlalchemy.dialects.mssql.base import SMALLDATETIME
  from superset.constants import TimeGrain
  from superset.db_engine_specs.base import BaseEngineSpec, LimitMethod
  from superset.errors import SupersetErrorType
  from superset.utils.core import GenericDataType
label_desc: Use image node_id 2 for calling the MssqlEngineSpec obj's underlying member method code with example usage: obj.convert_dttm(cls, target_type, dttm, db_extra) and returns: None, str, dttm, str, str, datetime_formatted, str, str, datetime_formatted, str