# How to advance or retreat 1 week by pressing button?

To allow a user to click the left button and retreat 1 week, and press the right button to advance 1 week - what’s the best way to do this?

Presumably, 4/26/2019 and 5/02/2019 are date objects (let’s call them date1 and date2).

One the date 1 week before date1 is:

`date1:+(days) -7`

Similarly, 1 week before date2 is:

`date2:+(days) -7`

So, on left click you just set date1 to date1:+(days) -7 and do the same thing for date2. On right click you add 7 days to both of them.

Aside: The thing being visualized here might be a date range and that date range would be the very starting moment of 4/26/19 (2019-04-26 00:00.000) to either 5/02/19 at the very end of the day (2019-05-02 23:59:59.999) OR the very beginning of 5/03/19 ( 2019-05-03 00:00:00.000)… depending on how you want to think about it.

In terms of how Bubble can operate on date ranges, the “contains point” operator includes the endpoint in its calculation. So, if you ask:

`date1<- range ->date2 contains point date2`

Bubble replies “yes”. So this would argue for constructing such a date range as:

2019-04-26 00:00.000 <- range -> 2019-05-02 23:59:59.999

… rather than ending at 2019-05-03 00:00:00.000

BUT, 2019-04-26 00:00.000+(days) 7 will yield us 2019-05-03 00:00:00.000. We can of course subtract one second or do +(days) 6 and set the time parts to 23 hours 59 minutes and 59 seconds… but in both cases we get a milliseconds part of .000 rather than .999.

I’m not 100% sure if that’s an issue in Bubble really (that is, is the precision of all date comparisons only down to the second?), but it’s annoying that we cannot make a millisecond-accurate “end of time” point.

@keith coincidentally I thought about creating a post to discuss the issues of exclusive dates. My Air Calandar plugin uses that for all day events and I know it’s going to trip some people up but it’s the correct thing to do.
You touched on some of the points here.

+1, @seanhoots! Yeah, this is why I prefer just doing fancy date stuff in moment/moment-range, where you have control of whether to include the end slice in the comparison. The Bubble date handling internals are either (1) inconsistent or (2) incomplete. I just find taking control of it with my own methods WAY easier.

Also, the issue of often not being able to do Date math on the needed side of the equation. Sometimes code is the way, right?