Date range BETWEEN doesn't include last date


#1

Hey Peeps (again),

In this other piston, it’s my Christmas Season piston. It assigns a variable to True or False. It’s been fine up untill today. It set FALSE because this is the last day in the BETWEEN range. Can this be modified to include today in that range? Would the end date work if WebCoRE instead see a range of:

Date is between { ’ Dec 1, { $year } ’ } and { ’ Jan 2, { $year }+1 ’ }

Cheers


#2

Try using if $monthname is ‘December’. Instead of range


#3

Why not just set your end date to tomorrow so today is “between” your beginning and end dates?

Edit to add: when you enter a date in any “between” formula, you have to imagine there is a 12:00 midnight stamp right behind it. That’s why your first condition included January 1st (because any time after midnight met it) but you have a dead spot between 12/31 at midnight and 1/1 at midnight.

Just change it to 12/1 thru 1/1 (or 12/1 thru 12/31 at 11:59:59 if you’re struggling with the year issue).


#4

If I use your suggestion, it should work, but it removes the ability to change what part of December is the initial start.


#5

In the end I might be overthinking this. It’s probably easier to just create a virtual Christmas switch, or set the @IsItChristmasSeason variable manually.


#6

What’s undesirable about the options I suggested?


#7

This is my Virtual Christmas switch turn on/off piston.


#8

I like this method as long as it runs on it’s own each year. I tried coding it, but can’t seem to be able to code in the TIME for the last day in Dec.

Expression:
‘Dec 31, {$year}’

How do I add the time in that?


#9

Date is between { ’ Dec 1, { $year } ’ } and { ’ Jan 2, { $year }+1 ’ }
which the intended result is maybe?
Date is between Dec 1, 2017 AND Jan 2, 2018

BTW I really like my idea of this Date is Between, but came to the conclusion it wouldn’t work due to the fact that once the year rolled over, the Dec year would also be changed in the IF. This would then become

Date is between Dec 1, 2018 AND Jan 2, 2018

At least that’s what I think.


#10

Will this not work for you? Or something like it anyway.

image


#11

Here’s my BST/GMT piston. What you want is very doable.
image


#12

It would work perfectly. The challenge is to make it open-ended enough that it doesn’t need editing every year. It’s more of an exercise of actually beating it and getting it to work as intended… without cheating. Otherwise since I would have to go in every year to alter the date, then I might as well just set the variable manually and be done with it. No fun in that… LOL.


#13

See what you mean.


#14

So would the expression be something like this?

‘Dec 31, {$year}, 23:59:59’

EDIT: Modified the statement…
Capture


#15

Not sure to be honest.
I was thinking this but I can’t say for sure.
image
EDIT.
With the time.
image


#16

I just tried this and it evaluates to true.

image


#17

I’m not sure, but I think mine might work.

I initially did (notice where I put the last single quote)…
‘Dec 31, {$year}’, 23:59:59
… but noticed an expression error in the logs.

When I changed it to (notice where I put the last single quote now)…
‘Dec 31, {$year}, 23:59:59’
… the error disappeared.

If I’m right, it seems the simplest.


#18

I like it.
Looks better and it works.

image

image


#19

I also just tried this and it also set the variable to TRUE like it’s supposed to.


#20

Nice one.
First day of the year and I’ve learned something. :smiley: