Is there a C# function which will give me the last day of the most recently finished Quarter given a date?
For example,
var lastDayOfLastQuarter = SomeFunction(jan 3, 2010);
would set lastDayOfLastQuarter = Dec 31, 2009
The calculation takes the integer (the number to the left of the decimal) and adds it to the deminal part of the number (the number to the right of the decimal) that has been divided by 25 to provide the correct quarter value. Answer Number: 000022991. Products.
When reporting time not worked, employees should round to the nearest 1/4 hour. For example: 15 minutes = 0.25 hours, 30 minutes = 0.50 hours and 45 minutes = 0.75 hours.
To round a number down to nearest 0.5, use the FLOOR function, for example =FLOOR(A2, 0.5) . To round a number up to nearest 0.5, use the CEILING function, for example =CEILING(A2, 0.5) . To round a number up or down to nearest 0.5, use the MROUND function, e.g. =MROUND(A2, 0.5) .
Enter this formula: =MROUND(A2,"0:15") or =MROUND(A2,"0:30") into a blank cell beside your data which need to round to nearest quarter or half hour, and then drag the fill handle down to the cells you want to apply this formula, and you will get a list of decimal numbers, see screenshot: 2.
A simple function can calculate the last days of the most recently completed month:
public static DateTime LastQuarter(DateTime date)
{
return new DateTime(date.Year, date.Month - ((date.Month - 1) % 3), 1).AddDays(-1);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With