MS SQL: How to get data from previous month.

May I ask how can I get data from previous month? I have Final_ClockIn field which server as my date. Our client execute this scipt every first of the month. So let say, january 2019, how can I get data from december 2018? This needs to be consistent everymonth.

This is what I have and I believe not correct : MONTH(Final_ClockIn) = DATEADD(MONTH,DATEDIFF(MONTH,0,GETDATE()) -1,0) AND YEAR(Final_ClockIn) = YEAR(getdate())

All I can see is for MySQL samples only. Thank you

Maximum number of options when selected via next and previous buttons?

I’m designing a product that has customizable features. The user can customize a light color by pushing a forward (>) or back (<) button. This action will toggle through a set color palette that will loop back once they reach the end.

I’m setting it up so that holding either button (< or >) will jog more quickly through the color options, but assuming the user is unaware that holding the buttons will run through them quicker…

And regardless of how many colors a user can distinguish or even needs…

How many options (aka. button presses) is enough before the user gets frustrated by toggling through them all? Any experience or studies to support this?

It’s safe to assume that toggling through 3 colors would not be annoying. However, toggling through 1,000 colors could be. I’m wondering if there’s some “sweet spot” in between.


To clarify these are physical buttons on a physical product.

Count max values compared with previous array

I try to count the number of values in a row that are equal are greater to MAX() value of a (part) of the column above.

For example: compared to the 3 cells above itself. In E comes the ‘count’. i marked the cells it should count with *.

enter image description here

My final array is about 200×5000… I already tried (cell E4 in example) stuff like: {=SUM(IF(A4:D4>=MAX(OFFSET(A1,ROW($ 1:$ 4)-1,0,3,1)),1,0))} {=COUNTIF(A4:D4,”>=”&MAX(OFFSET(A1,0,ROW($ 1:$ 4)-1,3,1)))}

Hoping that the ROW() & OFFSET function would split the MAX function over the columns… But none give a decent result. I can of course split the MAX() over 200 different columns on a different sheet. But I’m getting nightmare because i can’t get it done in a single array formula.