Need Help understand this query

g0009348

New Member
Joined
Sep 8, 2015
Messages
11
Hello All,

Please can you help me understand the following query.

Between (DateAdd("d",-DatePart("w",Now())+3,Now()))-28 And DateAdd("d",-DatePart("w",Now())+3,Now())

I have been given an old database to understand but i'm having trouble, understanding what a report is trying to produce.

Many thanks
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
There must have been a reason to go to all that trouble...
g009348 - since it's not your db but is probably your business, maybe this will help you to figure out why it was done this way. Assume that it is Tuesday, 09/08 when you run the query with this criteria expression (it's not really a query as you called it).

DatePart("w",Now())+3 This returns the weekday as a number, Sunday based, 3 days from Now().
Tuesday is (3) so it returns day 6 of the week (Friday).

DateAdd("d",- This would add negative 6 days from Now()) - Wednesday 09/02
-28 This moves back 28 days from that Wednesday; 08/05
DateAdd("d",-DatePart("w",Now())+3,Now() Again, adds negative 6 days to Now(), which would be 09/02
So it translates to "Between 08/05/2015 and 09/02/2015" (29 days, I think).

Hope I got it right.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,845
Messages
6,162,350
Members
451,760
Latest member
samue Thon Ajaladin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top