I'm trying to have 3 combo boxes for users to enter dates. The Month and Year combo boxes are very easy but I'm having trouble with the day combo box. I want this to be an intelligent box in that it will only display days based on the month, ie. 28 when month is set to February and 31 if on January.
I'm just wondering if there is an easy way I should look at to accomplish this, I tried some VBA that was unsuccessful.
What I have done is that I essentially used addItem for all days 1-28 and then had IF checks to see if i needed 29, 30 or 31 days. Errors occurred when I would go from a month with 31 days to 30 and then to 29/28 because it would attempt to remove 31 from the list but it wouldn't exist since when switching to the 30 day month got ride of 31. Unless there's a way to bypass this I need a pointer to the right direction.
You can say something like:
Me.cboDay.RowSource = "SELECT Number " _
& "FROM MyNumbersTable " _
& "WHERE Number < = " & Day(DateSerial(Me.cboYear,Me.cboMonth+1,0))
Where MyNumersTable is a table of integers
Note that
Day(DateSerial(2012,2+1,0)) = 29
Related
Is anyone able to help me convert the lastLogon and lastLogonTimestamp from Active Directory? I am pulling the data with Power Query and for my own user name I and the data is returned like this:
[users.lastLogonTimestamp]=131804496023891686
[users.lastLogon]=131808141012537325
I found this page on Microsoft Docs which states very clearly:
This value is stored as a large integer that represents the number of
100-nanosecond intervals since January 1, 1601 (UTC). A value of zero
means that the last logon time is unknown.
However I am struggling to get a logical result. I have tried converting nanosecond to days, and then adding the days integer to the starting date '1/1/1601' result. Since I have been actively logging in, I should be getting a date result around today's date, '09/10/2018'.
131804496023891686 / 86,400,000,000,000
= 1525.5150002765241435185185185185
_
1525 + '1/1/1601' = Wednesday, March 6, 1605
-- REFERENCES:
1) https://www.calculateme.com/time/nanoseconds/to-days/
2) https://www.timeanddate.com/date/dateadded.html?m1=01&d1=01&y1=1601&type=add&ay=&am=&aw=&ad=1525&rec=
3) https://learn.microsoft.com/en-us/windows/desktop/adschema/a-lastlogon
Okay so this is a DOH! moment... The answer was staring me in the face. I missed the fact that this was represented in 100 nanoseconds not 1 nanosecond.
(131804496023891686*100) / 86,400,000,000,000
152551.50002765241435185185185185
_
152551 + '1/1/1601' = Thursday, September 13, 2018
NOTE: So this result is actually 3 days in the future... not perfect, but what I am really looking for is just "Active accounts in the last 30 days", so I will consider this acceptably accurate.
This article was also helpful-- http://www.selfadsi.org/ads-attributes/user-lastLogonTimestamp.htm.
So, for PowerShell, I put all together as following
(Get-Date '1601-01-01').AddDays([long]::parse($objItem.lastlogon)*100/86400/1000/1000/1000)
Imagine rows A2:A11 = name of customer, Columns B1:AE1 = days of the month.
To make it easy:
Daily, we tally if customers purchase (quantity) and separate them with a + to get the total of that day purchase. (example: on 2nd day of the month (C2:C5)
Abe =44+54+10
John =22+10+40
Sara =40
Mary=10+10
Also we need to count total “sales cases” of the whole day (in the above example it is 3+3+1+2)= 9 to show in the last row of the day. (B12 in this example)
The logic is something like
=SUMPRODUCT(LEN(FORMULATEXT(C2:C5))-LEN(SUBSTITUTE(FORMULATEXT(C2:C5),"+","")))
But I’m getting NA.
reminder: when there are no "+" signs & the value is more than zero, it should count as 1.
help?
There is a trick to do this, which might end up a bit convoluted to achieve the end result you want
First, define a new name in Name Manager (in the Formula menu bar)
Name: FormulaText
Refers to: =GET.CELL(6,OFFSET(INDIRECT("RC",FALSE),0,-1))
Now if you have a formula in cell B3 of =10+20+30 enter =FormulaText in cell C3 and you will get the text version of the formula
You can now count + symbols in that formula using =LEN(C3)-LEN(SUBSTITUTE(C3,"+",""))
In your specific circumstances, I would offset all of this to the right of your spreadsheet, say by 35 columns, in which case you will need to change the definition of FormulaText accordingly.
A fair bit of set-up work, but the result should work automagically.
I am not very good with excel - however, I am trying to create a good time accounting sheet that suits our complicated needs.
However, this is only a user feature: I have a cell (dropdown using input validation) with all the months. Upon selecting a month, I would like column C to be populated (1.1, 2.1, etc...). However, column B has the weekdays included (Monday to Sunday, repeating 5 times). The date column is supposed to be populated based on Weekday and date.
Example, B6-B12 = Monday - Sunday.
If user input = January (2016) then,
because 1st of January = Friday put 1.1 to C10 because B10 = Friday and 1.2 to C11 and 3.1 to C12 etc....
http://postimg.org/image/xj3vbxh8v/
Could anyone give me an idea on how I could accomplish something like that?
TVM
maul0r
I could not see the screenshot of your data, but I did come up with what I think is a solution, based on your requirements.
I used the ranges you referenced in your description as best as I could, but you may need to adjust to suit your exact layout.
See the screenshot below (sorry it is not high quality, but I currently do not have my screenshot tool). Explanation of formulas is below the pic.
Assumes month drop-down list is in cell A1
G1 = =DATE(YEAR(NOW()),VLOOKUP(A1,$M$1:$N$12,2,0),1)
H1 = =TEXT(G1,"dddd")
C8 = =IF(C7="",IFERROR(INDEX($G$1,MATCH(B8,$H$1,0)),""),IF(MONTH(C7+1)=MONTH($G$1),C7+1,""))
Drag C8 down to fill all rows of days.
You will need to add one more set of days to make sure all days are shown for all months.
*Note: I have not figured out yet how to stop days from repeating after the month is finished, but will edit once I get the solution.
I'm working in SSRS and I'm trying to create dynamic month and year header columns to look like this:
Oct 2015 | Nov 2015 | Dec 2015 | Jan 2016 | Feb 2016
The code I've tried is this:
=MONTHNAME(Today), TRUE) & " " & YEAR(Now)
This gives the desired result, and I know if I do +1, it'll go to the next month or year, but what happens when it turns January? How can I make sure next year's months have 2016?Is this possible? Not sure if I'm making sense on this, but I can clarify if needed.
Basically, I have 12 columns that have the months in them, and the column names will slowly move to the left. How can I make sure the year corresponds with the correct month when the year changes?
Never mind I found my answer. Here's my solution if anyone else needs it. What I had to do was another if statement when the month's value was greater than 12, add 1 to the year value. If it's not, it will default to the current year.
=MONTHNAME(IIF(MONTH(Today)+4>12,MONTH(Today)+4-12,MONTH(Today)+4), TRUE) & " " &
IIF(MONTH(Today)+4>12,YEAR(NOW)+1,YEAR(NOW))
Thanks for the tips guys!
Glad you were able to figure out a way.
There's more than one way to skin a tauntaun:
=MONTHNAME(DATEADD("M", 4, Today()), TRUE) & " " &
YEAR(DATEADD("M", 4, Today()))
Im developing a simple application that show the daily budget until the next payment. For that I'm using momentJS.
The problem is that the logic in my application is wrong. Im, first finding what day is it, then I find the first day of the this month (date(1)), then I sum 1 month and 14 days. But whenever its the next month (as right now -02/12), it will, of course tell me that the next 15th is in February.
Long story short, how do I find the next 15th using moment?
Here is my application:
$scope.nextDate = moment().date(1).add(1, "months").add(14,"days"); //calculate when is the next 15th
$scope.difference = Math.floor(moment.duration($scope.nextDate.diff($scope.today)).asDays());
Thanks in advance!
Use a simple condition in the add method when calculating the nextDate.
$scope.nextDate = moment().date(1).add((moment().date() > 14 ? 1 : 0), "months").add(14,"days");
This will either add 0 or 1 months to your calculation based on the condition if current date is larger than 14 (modify to 15 if you want to count "next" 15th as today when it's actually 15th)