Query from month to month

Dear expert

Please read query below. This query will show from 2017-12-01 to today 2018-02-27 result, now I only want to see one month result. Any good way to do it? For exemple: I would like to show FROM 2017-12-01 to 2018-01-01 2018-01-01 to 2018-02-01 and 2018-02-01 to 2018-02-27

Thanks

DECLARE
	@SendoutMonth date = '2017-12-01'

SELECT *
FROM
	Invoice.Head H
WHERE
	H.DoElectronicInvoice = 1
	AND H.DateInvoice >= @SendoutMonth

Open in new window

LVL 1
WeTiAsked:
Who is Participating?
 
Scott PletcherConnect With a Mentor Senior DBACommented:
DECLARE
      @SendoutMonth date = '2017-12-01'

SELECT *
FROM
      Invoice.Head H
WHERE
      H.DoElectronicInvoice = 1
      AND H.DateInvoice >= @SendoutMonth
      AND H.DateInvoice < DATEADD(MONTH, 1, @SendoutMonth)
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>I would like to show FROM 2017-12-01 to 2018-01-01 2018-01-01 to 2018-02-01 and 2018-02-01 to 2018-02-27
Just for kicks and giggles give us a data mockup of how exactly you wish to see this.
0
 
WeTiAuthor Commented:
currentdate is: 2018-03-01, I would like to see the 2018-02-01 to 2018-03-01 result, and I would also want to see the 2018-01-01 to 2018-02-01 result as well.
0
 
WeTiAuthor Commented:
Thanks yes it worked, you basicly add more month to 2. Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.