Equivalent of Oracle RR date format in SQL Server
My question:
  
  Is there a way to express RR in T-SQL?


It can be done, for example, as



-- from date to string
SELECT FORMAT(datetime_field, CASE WHEN YEAR(datetimefield) &gt; 49 
                                   THEN 'yyyy-MM-dd' 
                                   ELSE 'yy-MM-dd' 
                                   END) AS date_formatted_as_RR, ...




-- from string to date
SELECT DATEFROMPARTS(CASE WHEN CAST(SUBSTRING(string_field,7,2) AS INT)&gt;49
                          THEN CAST(SUBSTRING(string_field,7,2) AS INT)+2000
                          ELSE CAST(SUBSTRING(string_field,7,2) AS INT)+2100
                          END,
                     CAST(SUBSTRING(string_field,4,2) AS INT),
                     CAST(SUBSTRING(string_field,1,2) AS INT)) AS date_interpreted_as_RR, ...