Question

I am using this query to get the result of a DateTime Dropdown. Query is:

SELECT CONVERT(VARCHAR(50), PeriodStartDate, 106) AS PeriodStartDate
FROM PayPeriod 

I want to populate it according to 14 days before current Date. Somewhat like this:

SELECT CONVERT(VARCHAR(50), PeriodStartDate, 106) AS PeriodStartDate
FROM PayPeriod
WHERE PeriodStartDate BETWEEN GETDATE() AND PeriodEndDate

Instead of GetDate() how to write it as GetDate() - 14Days ?

Was it helpful?

Solution

There is a DATEADD method.

DATEADD(DAY,-14,GETDATE())

http://technet.microsoft.com/en-us/library/ms186819.aspx

OTHER TIPS

Use DATEADD:

DATEADD(day, -14, GETDATE())
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top