我希望转换以下日期
select (CONVERT(varchar(11), DATEADD(year, + 1,CONVERT(varchar(11), getdate(),111)))),datename(month,getdate()) for it returns 'jun 26 2015' ,'JUne'
我需要它返回以下'2015/6',6月
在使用获取日期时,这给了我想要的东西
select CONVERT(varchar(7), getdate(), 111) = 2014/06
但我需要在我的timewait字段上+1年。
我的实际代码如下:
SELECT c.account_owner_by_SalesDiv, CONVERT(varchar(7), a.timeWait, 111)as rollingdate, DATENAME(MOnth, a.timeWait)
FROM SalesForce.dbo.SalesForceContact AS b INNER JOIN
Dossier_Replication.dbo.vw_SFAD_Contact_data AS c ON b.ContactID = c.CONTACTID__C RIGHT OUTER JOIN
satVRS.dbo.rptNECACallHistory AS a ON b.UserID = a.UserID_Caller
WHERE (b.Platform = 'HandsonVRS') AND (a.timeWait BETWEEN CONVERT(varchar(10), DATEADD(year, - 1, CONVERT(varchar, DATEADD(month, DATEDIFF(month, 0,
GETDATE()-1), 0), 120)), 120) AND CONVERT(varchar, DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0), 101)) AND (a.isReport = '1') AND (a.NECA_isReport = '1') AND
(a.ConvoTime > '0') AND (c.account_owner_by_SalesDiv IN ('Enterprise Account', 'National Account', 'Major Account', 'House Account', 'Inside Sales Account'))
GROUP BY c.account_owner_by_SalesDiv, CONVERT(varchar(7), a.timeWait, 111), DATENAME(MOnth, a.timeWait)
order by rollingdate
提前致谢。
答案 0 :(得分:0)
这会给2015/06, June
:
SELECT
CONVERT(VARCHAR(7), DATEADD(YEAR,1,GETDATE()), 111) + ', ' + DATENAME(MONTH,GETDATE())
如果你不想要前导零,你可以使用SUBSTRING函数来修剪它。