What would the Sql syntax look like if I wanted to select +/- 10 days of a d
elivery date.
For instance; Table has Actual Delivery Date & Expected Delivery date, and u
sing the ABS Sql function, I want to select only the rows from the table tha
t were delivered with +/- 10 days.
And even if it's not the best way to do it, I would really like the info on
ABS.
Any ideas?
Thanx!Use DATEADD function like:
BETWEEN DATEADD ( d, -10, dt ) AND DATEADD ( d, 10, dt )
Anith|||I don't know your table structure or sample data, but here's a guess:
WHERE ABS(DATEDIFF(DAY, ActualDate, ExpectedDate)) <= 10
"Jude" <judes@.email.uophx.edu> wrote in message
news:%23NQBlSwQGHA.1868@.TK2MSFTNGP09.phx.gbl...
What would the Sql syntax look like if I wanted to select +/- 10 days of a
delivery date.
For instance; Table has Actual Delivery Date & Expected Delivery date, and
using the ABS Sql function, I want to select only the rows from the table
that were delivered with +/- 10 days.
And even if it's not the best way to do it, I would really like the info on
ABS.
Any ideas?
Thanx!|||Trust me I would, but someone taking a class asked me this question & I said
I had never used this function, but knew where to go to ask the experts!
Thanx!
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:u1RNgfwQGHA.4960@.TK2MSFTNGP12.phx.gbl...
> Use DATEADD function like:
> BETWEEN DATEADD ( d, -10, dt ) AND DATEADD ( d, 10, dt )
> --
> Anith
>|||Fantastic, Thanx so much Aaron! This is a favor for a friend who is taking
a class, and since I haven't used this function & would just use DateDiff
functions, I didn't have an answer. I knew the experts in here would
though!
Thanx again!!!!!
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:e%23zWkBxQGHA.1160@.TK2MSFTNGP09.phx.gbl...
>I don't know your table structure or sample data, but here's a guess:
> WHERE ABS(DATEDIFF(DAY, ActualDate, ExpectedDate)) <= 10
>
> "Jude" <judes@.email.uophx.edu> wrote in message
> news:%23NQBlSwQGHA.1868@.TK2MSFTNGP09.phx.gbl...
> What would the Sql syntax look like if I wanted to select +/- 10 days of a
> delivery date.
> For instance; Table has Actual Delivery Date & Expected Delivery date, and
> using the ABS Sql function, I want to select only the rows from the table
> that were delivered with +/- 10 days.
> And even if it's not the best way to do it, I would really like the info
> on ABS.
> Any ideas?
> Thanx!
>
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment