Home Between dynamic dates
Reply: 2

Between dynamic dates

kazzi Published in 2017-11-13 19:15:43Z

So part of my query, I would like to filter the results to show just the ones between a set date range, however, that date range is dynamic, based on an event.

For example:

WHERE date d
   BETWEEN '2017-01-01'         -- just a sample fixed date
   AND DATEADD(D, CONTACT_DATE, -1) -- to show a day before Contact Date

Basically just trying see if there was another CONTACT_DATE this year, excluding the day of the actual contact.

I know there could be other ways to do this, but I was wondering if I can tweak a query with the current logic.


Argument data type datetime is invalid for argument 2 of dateadd function.

dns_nx Reply to 2017-11-13 19:25:35Z

You mixed the parameters. The syntax is this:

DATEADD (datepart , number , date )

You should change it to this:


See here the docs: https://msdn.microsoft.com/de-de/library/ms186819(v=sql.120).aspx

Chris Mack
Chris Mack Reply to 2017-11-13 19:24:31Z

It should be:

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.319728 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO