SQL Server adding the slashes to the date on the fly

前端 未结 2 1816
攒了一身酷
攒了一身酷 2021-01-29 12:38

I am trying to figure out how to add some sort of mask to my data. Currently I have a query like this:

SELECT [EmployeeTC_No] AS \"Employee TC#\"
      ,[pye_nla         


        
2条回答
  •  孤城傲影
    2021-01-29 13:13

    This is not ideal, since you appear to not be storing dates as a date type. If they are varchars, and you want to just add slashes for presentation, you can insert them where needed. This is assuming you always have a 8char date:

    SELECT STUFF(STUFF(your_col, 3, 0, '/'), 6, 0, '/')
    

提交回复
热议问题