Is there a way to use a variable/combo box to select a year in a date without using date picker - vba

I am working on a calculator to track my (and my coworkers may use it) overtime at work. We have a bunch written in excel, but I am trying to do one in access. There is probably a simple solution, but having searched for a couple days for using a variable in a date has only given me how to use the date as a variable. So our pay periods are defined 1/1/yyyy to 1/15/yyyy etc. Hour pay is calculated on the number of days we have in a pay period which varies every year by days off. I have it calculating the proper number of days using VBA, but I am having difficulty getting it to use the combo box year which defaults to current year.
I have tried setting the control source to = 01/01/[cmbYearselect]
using variables, creating a string in vba and format date
Any help would be appreciated as I am going to have to use the variable in both the control sources and vba code.
Thank you
01/01/[cmbYearSelect] results in 12/30/1899 on my form
everything else has resulted in a type mismatch for the variables etc.

Use CDate with no year:
=CDate(#01/01#)
or:
=CDate("01/01")
to have primo of the current year.

Related

Google Sheets monthly sum code optimization

Good day everybody, we are making a spreadsheets for incoming cash monitoring, and I feel like the method I used to achieve the monthly sum is possibly the worst.
So I was wondering if some of you guys have a shorter solution
=SUM(FILTER('Dashboard'!D2:D;'Dashboard'!E2:E="Incoming";'Dashboard'!C2:C>=DATE(text(today()-text(today();"dd");"yyyy");(text(today()-text(today();"dd");"mm"));(text(today()-text(today();"dd");"dd")));'Dashboard'!C2:C<=DATE(text(today();"yyyy");(text(today();"mm"));(text(today();"dd")))))
So since this looks like a cluster**** of code, i will try to annotate it:
=SUM(FILTER('Dashboard'!D2:D;'Dashboard'!E2:E="Incoming"
Sort by only the incoming cash and not outgoing
;Dashboard'!C2:C>=DATE(text(today()-text(today();"dd");"yyyy");(text(today()-text(today();"dd");"mm"));(text(today()-text(today();"dd");"dd")));'Dashboard'!C2:C<=DATE(text(today();"yyyy");(text(today();"mm"));(text(today();"dd")))
The range is from 1'st day of the month to todays date.
Method: Get todays date, and subtract todays date, to get the first day of the month.
Which isn't even a true monthly sum, rather than up to current day sum.
I'm really sorry but due to company policy I cant link the file itself, but the sheet is rather simple
The columns are:
Date, Sum, "Incoming/Outgoing", "Cash/Credit"
I also have a weekly sum, but I feel like that formula is somewhat decent
=query(filter('Dashboard'!C2:D;'Dashboard'!E2:E="Incoming";weeknum('Dashboard'!C2:C;1)=weeknum(today();1));"Select Sum (Col2) label Sum(Col2)''";-1)
There's no need to format the date to 'yyyy-mm-dd'. You can use EndOfMONTH to get the last day of last month.
=SUM(FILTER('Dashboard'!D2:D;'Dashboard'!E2:E="Incoming";'Dashboard'!C2:C>EOMONTH(TODAY(),-1);'Dashboard'!C2:C<=TODAY())

Static Month Every Year Parameter SSRS

I want to have a parameter that selects the same month (which is September) every year. So this Parameter dynamically changes every year but still selects September.
It was all about changing the month the the static date. Took me a few tweaks but I was able to figure it out. It was actually pretty easy stuff. Feel free to post other methods. Method I used was:
=dateadd("m",-1,dateserial(year(Today()),9,1))

Excel - VBA - Access: Date Selection Solution

I'm looking for a direction, assuming that surely someone has had to do something similar and I'm making this more difficult than it is.
We have an Access DB, feeds to a pivot table in Excel, which is in turn used to supply charts for a "user dashboard." This is 2010, so no slicers.
My problem is that that DB is updated adding months to a field. There is a listbox in the dashboard that will allow the user to select a specific month and see stats for that time. I'm having a couple problems even getting started and would like to make sure I'm going about this the simplist/most efficient way.
My thought was to populate the listbox with the 'month' fields from the pivot table. I'm not quite sure how I'm going to do that with VBA (I have a couple ideas), but if that's the best route then I'll figure it out.
But, has anyone had a similar need, and found a better solution? I have a bunch of buttons to handle other fields, but I would really like to allow for the user to select a date/month/range...whatever. Surely this is a common, easily managed desire, no?
I'd put this in with the conversation you're having with a couple of people above, but I don't have enough rep to do that yet.
I had a similar dashboard issue years ago. Resolved it by adding a dropdown beside the month box (which was a dropdown in my case, not a listbox) with the options "Year to date" and "Month to date". By definition selecting a past month and MTD gave you the whole month, whereas selecting the current month can only ever give you MTD. Same thing with YTD - it would give you the combined stats for the current year to date instead of just one month.
The month dropdown in my dashboard was populated based on the current data in the pivot, which in turn was controlled from the database. We used a 25-month rolling select for the data and showed only the last 13 months in the month dropdown. That gave us a full 12 month spread of historical data to work from if someone chose the oldest month we offered them, yet kept the size of the pivot cache manageable
I used a dropdown for the options instead of option buttons or a checkbox, because I had a suspicion that delivering what was asked for would lead to additional requests. I was right. Eventually we had options for "Last year to date" (how we were tracking this day last year), "Quarter to date", "Financial year to date", and so on. Adding extra choices to the dropdown box was easier than rearranging the dashboard to accommodate the proliferating requirements.

SSRS 2008 R2 calulate new date from existing that's 1 year later and on Monday?

hoping someone can help. I have an textbox on a report that I need to calculate a new date value for from another date on the report.
I need to take an existing shipping date (say 5/5/2014) and calculate a new date which is one year later but on the Monday of that week (so would be 5/4/2015) -- we only ship product on Mondays.
I know I need to use DateAdd and probably DatePart but have been unable to find the proper formula.
can anyone help?
figured it out -- thanks for all the help. I took the idea that Gordon had, putting it in my select statement rather than trying to manipulate it in the expression area of the textbox on the report:`SELECT DATEADD(wk,DATEDIFF(wk,0,DATEADD(YY,1,o.REQ_DATE)),0) as NewDate'
works great! :)

SSRS question on calculating dates from a grouped field

I have a SSRS field called dates. I calculated the difference between the last and beginning date using the following code:
=Code.MinutesToHoursMinutes(DateDiff("n",FIRST(Fields!Date.Value), LAST(Fields!Date.Value, "grp_Order")))
The Code.MinutesToHoursMinutes is jsut a function that makes it Hours Minutes format.
How do I now average all of these?????
Average on what, given you are already using FIRST and LAST? And why only a scope for LAST too please?
Anyway, the average is on DateDiff("n",FIRST(Fields!Date.Value), LAST(Fields!Date.Value, "grp_Order")) or other expression rather then the Code.MinutesToHoursMinutes function, no?
So in the average text box:
=Code.MinutesToHoursMinutes(Avg(`DateDiff("n",FIRST(Fields!Date.Value), LAST(Fields!Date.Value, "grp_Order"))
... or something similar.