我试图弄清楚如何为我的数据添加某种掩码。目前,我有这样的查询:
SELECT [EmployeeTC_No] AS "Employee TC#" ,[pye_nlast] AS "Name Last" ,[pye_nfirst] AS "Name First" ,[Dept] AS "Department" ,[pye_status] AS "Active" ,[HireDate] AS "Hire Date" ,[SeparationDate] AS "Separation Date" FROM [testing].[dbo].[testing]
聘用日期和离职日期列中的数据显示为09282015,但我需要日期来显示斜杠(“ /”),例如09/28/2015,有什么办法可以为这些添加即时遮罩吗?
这是不理想的,因为您似乎没有将日期存储为日期类型。如果它们是varchars,而您只想添加斜杠以进行演示,则可以在需要的地方插入它们。这是假设您始终有一个8个字符的日期:
SELECT STUFF(STUFF(your_col, 3, 0, '/'), 6, 0, '/')