谁能帮我将此 Microsoft 访问查询转换为 Tsql 2008:
SELECT
dbo_Invoiceable__c.NAME AS Invoiceable,
dbo_Invoiceable__c.Payment_is_due__c,
dbo_Invoiceable__c.Day_Due__c,
DATE () AS [Invoice Date],
DateSerial(Year(DATE ()), Month(DATE ()), [Day_Due__c])
AS [On a day of the month],
DateAdd("d", [day_due__c], DATE ())
AS [In a given number of days],
DateAdd("d", [day_due__c] - 1, DateAdd("m", 1, DateSerial(Year(DATE ()), Month(DATE ()), 1)))
AS [No of days after EOM],
IIf([Payment_is_due__c] = "In a given number of days", [In a given number of days], "") & IIf([Payment_is_due__c] = "On a day of this month", [On a day of the month], "") & IIf([Payment_is_due__c] = "No of days after EOM", [No of days after EOM], "")
AS [Due Date]
FROM dbo_Invoiceable__c;
我试过这个:
SELECT *,
CASE
WHEN [Payment_is_due__c] = 'In a given number of days' THEN [In a given number of days] ELSE ''
END + CASE
WHEN [Payment_is_due__c] = 'On a day of this month' THEN [On a day of the month] ELSE ''
END + CASE
WHEN [Payment_is_due__c] = 'No of days after EOM' THEN [No of days after EOM] ELSE ''
END AS [Due Date]
FROM (SELECT [SalesForce_LIVE.dbo.Invoiceable__c].[Name] AS Invoiceable,
[SalesForce_LIVE.dbo.Invoiceable__c].[Payment_is_due__c],
[SalesForce_LIVE.dbo.Invoiceable__c].[Day_Due__c],
CONVERT (DATETIME, CONVERT (VARCHAR, GETDATE(), 1), 1) AS [Invoice Date],
dbo.DateSerial(Year(CONVERT (DATETIME, CONVERT (VARCHAR, GETDATE(), 1), 1)), Month(CONVERT (DATETIME, CONVERT (VARCHAR, GETDATE(), 1), 1)), [Day_Due__c]) AS [On a day of the month],
DATEADD(d, [day_due__c], CONVERT (DATETIME, CONVERT (VARCHAR, GETDATE(), 1), 1)) AS [In a given number of days],
DATEADD(d, [day_due__c] - 1, DATEADD(m, 1, dbo.DateSerial(Year(CONVERT (DATETIME, CONVERT (VARCHAR, GETDATE(), 1), 1)), Month(CONVERT (DATETIME, CONVERT (VARCHAR, GETDATE(), 1), 1)), 1))) AS [No of days after EOM]
FROM SalesForce_LIVE.dbo.Invoiceable__c) AS Nested1;
但仍然无法让日期序列在 Tsql 中工作