How to get the exact date with months? - asp.net-mvc-5

In my project, I put the date like 11/27/2020 and period for next exam 6 months OR 3 months
How can I get the exact date?
I use date calculating in my SQL with days or years working fine but with months no I tried 183 days and 182 days but it doesn't get The exact date.
I can deal with commands in SQL or the ASP.NET MVC controller but I miss the exact calculation.
Even if there is a good adding from NuGet packages can do that.
Thank you in advance

Related

Nesting DATEDIF and IF Statements in Excel

I am trying to create an Excel formula that will display someone's age in units of days, weeks, months, or years, depending on how old they were at the time of a test. To clarify...
If younger than 7 days, report the age in days
If older than 7 days but younger than 8 weeks, report the age in weeks
If older than 8 weeks but younger than 24 months, report the age in months
If older than 24 months, report the age in years
I have tried several functions for this, all using the DATEDIF function. For each, I have returned the #NAME? error. Please see below
KEY:
E600 = Date of Test
F600 = Date of Birth
I am using 7 days = 1 week, 60 days = 2 months, 730 days = 24 months = 2 years, etc.
Note: I also want to display "d/o" (days old), "w/o" (weeks old), "m/o" (months old), or "y/o" (years old) after each value, depending on the units that age is being reported in.
\\\\\\\\\\\\
=IFS((E600-F600)<7,DATEDIF(F600,E600,”d”)&” d/o”,AND((E600-F600)>7,(E600-F600)<60),(DATEDIF(F600,E600,”d”)/7)&” w/o”,AND((E600-F600)>60,(E600-F600)<730),DATEDIF(F600,E600,”m”)&” m/o”,(E600-F600)>730,DATEDIF(F600,E600,”y”)&” y/o”)
\\\\\\\\\\\\\
=IFS(DATEDIF(F600,E600,”d”)<=6,DATEDIF(F600,E600,”d”)&” d/o”,AND(DATEDIF(F600,E600,”d”)<=59,DATEDIF(F600,E600,”d”)>=7),DATEDIF(F600,E600,”d”)/7&” w/o”,AND(DATEDIF(F600,E600,”d”)>=60,DATEDIF(F600,E600,”m”)<=24),DATEDIF(F600,E600,”m”)&” m/o”,DATEDIF(F600,E600,”m”)>25,DATEDIF(F600,E600,”y”)&” y/o”)
\\\\\\\\\\\\\
=DATEDIF(F600,E600,IFS((E600-F600)<7,”d”&” d/o”,AND((E600-F600)>7,(E600-F600)<60),”d”/7&” w/o”,AND((E600-F600)>60,(E600-F600)<730),”m”&” m/o”,(E600-F600)>730,”y”&” y/o”))
\\\\\\\\\\\\\\
Any help on this would be greatly appreciated!
=LOOKUP(E600-F600,{0,8,56,730},INT(DATEDIF(F600,E600,{"d","d","m","y"})/{1,7,1,1})&" "&{"d","w","m","y"}&"/o")
though your listed criteria state only "if younger than", "if older than", so it's not clear in which category someone who, for example, is precisely 7 days old should lie.
#Jos Woolley's example worked great. Another solution is posted below if anyone is troubleshooting their own formula in the future.
=IF(E600 < F600 + 7, DATEDIF(F600, E600, "d") & " d/o", IF(AND(E600 >= F600 + 7, E600 <= EDATE(F600, 2)), ROUNDDOWN(DATEDIF(F600, E600, "d") / 7, 0) & " w/o", IF(AND(E600 >= EDATE(F600, 2), E600 <= EDATE(F600, 24)), DATEDIF(F600, E600, "m") & " m/o", DATEDIF(F600, E600, "y") & " y/o")))

Working out calendar days from week number and day (42.1)

struggling to find anything on here regarding my query, which leads me to believe it may be impossible but here goes!
my company creates products that take takes around two weeks to fully build from start to finish. The whole company works in weeks and days, for example we would start building on week 14.1 (14th week and on Monday) and finish building on week 16.5 (16th week and on Friday). The company is massive so I cannot convert them to use dates instead.
We want to capture data from a spreadsheet that has 5 columns, A = build week , B = build day, C = Completion week, D = Completion day, E = calendar days.
At present we just manually work out the amount of calendar days as it is difficult to write a formula to differentiate between knowing week 52.5 and week 1.1 is only 4 days.
is it possible to write a formula or use a VBA code to work out the amount of calendar days between two week numbers from the data I have or am I testing the limits of excel?
any help would be great.
Use:
=((C2+(C2<A2)*52)*7+D2)-(A2*7+B2)+1

Calculate past 12 and 6 month Average

The excel user will export the data from an online website to excel (12 months data), so the data will be all the time different.
I need the past 6 months and 12 months average (However, the calculation need to use the months I have in the data, and sometimes there will be less then 6 or 12 months), but I still need to get the average and frequency for it , however, I am not sure how to get it.
I am trying to write a code, but it is not complete and is not working as well, I don't get an error; it just doesn't work.
I am open for Excel formulas as well, the problem may be the last row and that it need to use the data I have to calculate and not 6 and 12 months full.
PS: I post a similar question on https://www.ozgrid.com/forum/index.php?thread/1227312-dynamic-way-to-calculate-the-last-6-months-average/
Will This formulas work for you?
Average for last 6 months:
=AVERAGEIF(A:A;">="&EDATE(MAX(A:A);-6);B:B)
Frequency for last 6 months:
=IF(MONTH(MAX(A:A)-MIN(A:A))>=6;COUNTIF(A:A;">="&EDATE(MAX(A:A);-6))/6;COUNTIF(A:A;">="&MIN(A:A))/MONTH(MAX(A:A)-MIN(A:A)))
Average for last 12 months:
=AVERAGEIF(A:A;">="&EDATE(MAX(A:A);-12);B:B)
Frequency for last 12 months:
=IF(MONTH(MAX(A:A)-MIN(A:A))>=12;COUNTIF(A:A;">="&EDATE(MAX(A:A);-12))/12;COUNTIF(A:A;">="&MIN(A:A))/MONTH(MAX(A:A)-MIN(A:A)))

excel - timesheet if day before and day after holiday worked

I currently have if the holiday add 8 hours with the following formula.
=IF(SUMPRODUCT((LEFT(TEXT(B5,"mmm"),3)=LEFT(Holidays!$B$2:$B$11,3))*(DAY(B5)=--RIGHT(Holidays!$B$2:$B$11,2))),8,0)
I think what I'm asking for would go where the 8 currently is.
So what I am attempting to do is only add those 8 hours if the scheduled working day before the holiday, and the scheduled working day after the holiday is worked. Now I know this wont put the +8 hours in until the information for the following day is entered but that is fine as long as the week end totals include the holiday.
Is there any way I can go about achieving this?
So, as a temporary solution you can use this in place of 8, in L6 cell:
IF(AND(OFFSET(L6,-1,-3)=8,OFFSET(L6,1,-3)=8),8,0)
You can modify conditions, so they will fit your case in the best way.
This works for Monday-Friday only!

Excel - Find if worker has worked certain OT if weekday and or Sunday

I have a worksheet with days running along the columns, within each day there are different hourly categories, 130%, 150%, 200% and 215% etc, there are other categories within each day, but these are not to be included. (Can't post Image as new, can email?)
If a worker works over 3.5 hours in any of these categories they get an extra lunch, except on Sunday's where they must work 4 hours.
I've been using countif's to check each day over 3.5, and another column for Sunday's.
The weekday and Sunday can be combined into the same column as the lunch price is still the same, just number of working hours different.
The main problem is I have to adjust the countif's every month, I want something that will look at days of the week and/or sunday's and check without adjusting every month.
Have been trying to get my head around sumproduct with countif!
Any help, very much appreciated.
Thanks!
Since you have not mentioned what is where this might take some adjustment, but may get you started:
=IF(SUM(B3:G3)>=IF(WEEKDAY(B$1)=1,4,3.5),"lunch","no lunch")

Resources