I need to automatically set a value of 8.45 hours work for the winter schedule (01 October till 15 June) and 6 hours work for a summer schedule (16 June till 30 September) for a time sheet done in Microsoft Excel.
The equation I am trying is the following:
=IF(AND(DATE($G$1,6, DAY(15))>=(DATE($G$1-1, 10, DAY(1))));(DATE($G$1,6, DAY(15))<A8;8.45;"")
But this keeps on returning formula errors and this still omits the rate value for the summer schedule.
$G$1 is the year that is manually inputted for the yearly time sheet.
A8 is the current date.
Any guidance into this equation would be appreciate.
With best regards Fab
Edit
Thanks DirkReichel, Scott Craner, Alex Bell, Michael Uray for your great intervention.
I tried all the suggestions but some returned a =VALUE error and some did not omit the winter schedule as from the 1 October ->
This is the correct equation:
=IF(AND(DATE($G$1,9,30)>=A8,DATE($G$1,6,15)<=A8),6,8.45)
The equation checks the current date being A8 and checks if it falls withing the summer period (date range). If current date falls within the summer period the value is returned to 6, if the current date falls outside the summer period, it returns a value of 8.45.
Thanks to all that guided.
Depends on the regional settings, you may use comma "," instead of ";" as shown in the following example:
=IF(AND(NOW()>DATEVALUE("6/15/2016"), NOW()<DATEVALUE("9/1/2016")),6,8.45)
Hope this may help.
Try this:
=IF(AND(DATE($G$1,6,15)>=A8,DATE($G$1-1,10, 1)<=A8),8.45,6)
The following solution should work for you:
A1 is the date which gets checked, the formula is placed in B1.
On this way you can pull down a list of dates and formulas in your sheet.
=IF(AND(A1>DATE(YEAR(A1),6,15),A1<DATE(YEAR(A1),8,1)),6,8.45)
It checks if the data is in the range of YYYY-06-15 and YYYY-08-01 and sets then the output to 6, or if it is not in this range to 8.45
I did test it with e German Excel Version with the following formula and I translated it then manually in Notepad to the English formula version.
=WENN(UND(A1>DATUM(JAHR(A1);6;15);A1<DATUM(JAHR(A1);8;1));6;8,45)
I hope my formula translation will work for you in the English Excel version.
Related
I am looking to save an individual worksheet from a workbook with today's date in the filename. ex. (c:\HotDogS\sales\Daily_12_04_16.xslx)
The problem I am encountering is getting the date to show right in the filename.
I have 1 cell that has the simple formula of =TODAY(). The cell is formatted for mm/dd/yy.
The formula I am trying to use to save the date for the sheet is:
=left(B3,2)&"_"&mid(B3,4,2)&"_"&right(B3,2)
So I am expecting a date of 12/04/16 to come out as 12_04_16, but I am getting is, 42_08_08.
Can somebody shed some light on this??
Thank you!!
Assuming TODAY is 4 December 2016, i.e. serial day number 42708, your formula is:
=left(B3,2)&"_"&mid(B3,4,2)&"_"&right(B3,2)
Left(B3,2) is 42. Mid(B3,4,2) is 08. Right(B3,2) is 08.
So your final result is 42_08_08.
You probably want to use (as an Excel formula):
=TEXT(B3,"mm\_dd\_yy")
Or in VBA you could use
Format(Range("B3").Value, "mm_dd_yy")
Excel stores dates as the number of days (and fractions of a day) since 0 January 1900. Therefore
1 January 1900 is day 1
31 January 1900 is day 31
1 February 1900 is day 32
29 February 1900 (even though it doesn't exist - but the bug has been maintained for backward compatibility) is day 60
1 January 1901 is day 367
4 December 2016 is day 42708
NOW() is day 42709.328 (it's about 7:52am on 5 December 2016 at the moment)
Referencing a cell formatted as date returns the underlying date serial number.
To get a date formatted as you want use
=TEXT(B3,"dd\_mm\_yy")
We have a process at work that runs every 31 hours and would like to have a column in an Excel 2010 spreadsheet that reflects the time and dates the process is due to run each day over the coming year e.g.
start date (Cell:A1):
10/31/2016 1:00
11/1/2016 8:00
11/2/2016 15:00
11/3/2016 22:00
11/5/2016 5:00
11/6/2016 12:00
11/7/2016 19:00
11/9/2016 2:00
11/10/2016 9:00
11/11/2016 16:00
11/12/2016 23:00
11/14/2016 6:00
I am currently using the formula: A2 =A1 + (31/24) to populate the dates and times in the column which appears to work ok. I need to insert a blank row between days that are not consecutive (in order to highlight that fact, to make it easier for the operators to read and not instigate the process at the wrong time!) which is where the difficulty lies. I am assuming that I will need a separate VBA function to step through each cell and compare the day date (ignoring time value.) in the previous cell, if day date is greater than 1 (as in not the following day.) insert a blank row.
I am looking for a solution to the following scenario but am struggling to get my head round it and would appreciate any guidance/ help anyone is able to provide.
Many thanks
You do not need a VBA Function for that, it can be accomplished with the function
A3 = IF(A2="",A1+31/24, IF(INT(A2+31/24)=INT(A2)+1,A2+31/24,""))
*For that to work, you will have to populate cells A1 and A2 manually, though.
You can use the INT() function to get the date part of a DateTime field, so it becomes simple to check if adding 31 hours will leave a 1 day gap in the sequence by checking INT(A2+31/24) = INT(A2)+1.
So, to explain the function, the part
IF(INT(A2+31/24)=INT(A2)+1,A2+31/24,"")
will check if the days are consecutive, and if so, it will fill the DateTime. If not, it will leave it blank.
The outer IF checks if the cell above is blank. If it is, the function will use the one above that.
I have two columns called
1ST column Calendar Date:
16/02/2015
2nd Column Previous Day:
Yes
Formula I am currently using:
if([calendar Date])=today-1,"YES","NO").
The 2nd column returns value based on the 1st column.
However , the problem I am getting is when I run the data on monday when we have calendar date (day on friday). So it is showing "NO" as formula only returns data for previous day.
So I want something like this
Only when I run on Monday it should give me if([calendar Date])=today-3,"YES","NO").And all other workdays if([calendar Date])=today-1,"YES","NO")
Can you please help me on this.
If you cell A2 has the calender date then try with below formula.
=IF(WEEKDAY(A2)=6,(IF(A2=TODAY()-3,"YES","NO")),(IF(A2=TODAY()-1,"YES","NO")))
=IF(WEEKDAY(TODAY())=2,IF(TODAY()-3 = A12, "YES", "NO"), IF(TODAY()-1 = A12, "YES", "NO"))
first, identify whether the date today is monday or the other day of the week.
IF(WEEKDAY(TODAY())=2
If today is monday, then you can create the condition that the previous day must be friday [today()-3].
IF(TODAY()-3 = A12, "YES", "NO")
If today is not monday, then create the condition that the previous day is the date yesterday [today()-1].
IF(TODAY()-1 = A12, "YES", "NO")
To disregard weekends and holidays, you will want either the NETWORKDAYS or
NETWORKDAYS.INTL¹ function. Not only can you skip a conventional Sat/Sun weekend but you can add a reference to a list of holidays to be discounted as well. The newer NETWORKDAYS.INTL has a large selection of built-in non-standard 'weekend' formats or you can write your own. e.g. "0000011" is a standard Sat/Sun weekend and "0101000" is a Tue and Thu 'weekend'.
Both NETWORKDAYS and NETWORKDAYS.INTL count the number of days inclusively so you are looking for a value of 2, not 1.
For the following example, I've reset the computer's system date to Tue 19-Jan-2016 (the day after Martin Luther King Day, 2016).
=IF(NETWORKDAYS.INTL([#[calendar Date]], TODAY(), "0000011", Z$2:Z$11)=2, "Yes", "No")
If you wanted to get a little more elaborate, just use the NETWORKDAYS.INTL function with a custom number format of [=2]\Y\e\s;\No;\No. This allows you to retain the actual underlying value of the NETWORKDAYS.INTL formula while displaying Yes or No.
The results from the image above clearly show that both the weekend and holiday were discarded from consideration and that Fri 15-Jan-2016 is considered the previous day.
¹ The NETWORKDAYS.INTL function was introduced with Excel 2013. It is not available in earlier versions.
I'm looking for a way to convert an ISO date to Month and I also need to covert an ISO week to Month.
I need to do this in Excel and Access.
I found this formula for excel but when converting it to Access it does not work. Is there a simple way to accomplish this?
I found this Excel formula to convert ISO date to month (C2=date) and it works perfect:
=MONTH(DATE(YEAR(C2),MONTH(C2)+(WEEKDAY(C2,2)+(DAY(DATE(YEAR(C2),MONTH(C2)+1,0)))-(DAY(C2))<4),(((7-(WEEKDAY(C2,2)))+(DAY(C2)))>3)))
But when I modify it for an Access query it does not return the correct values:
Date_to_Month:MONTH(DATESERIAL(YEAR([WW_Index].[ISO_date]),MONTH([WW_Index].[ISO_date])+(WEEKDAY([WW_Index].[ISO_date],2)+(DAY(DATESERIAL(YEAR([WW_Index].[ISO_date]),MONTH([WW_Index].[ISO_date])+1,0)))-(DAY([WW_Index].[ISO_date]))<4),(((7-(WEEKDAY([WW_Index].[ISO_date],2)))+(DAY([WW_Index].[ISO_date])))>3)))
I also need to convert ISO week_year to Month. I found this formula but it does not work:
=MONTH(DATE(YEAR(C2),1,-2)-WEEKDAY(DATE(YEAR(C2),1,3))+D2*7)
Example: week 18, 2012 is the ISO week of Apr 30 through May 6, 2012. There is less that 4 April days in this week thus week 18, 2012 is in May.
Any help would be greatly appreciated.
I don't know access but you can do the first part (date to month) much more easily in excel with this formula
=MONTH(C2-WEEKDAY(C2-1)+4)
That should be easier to convert for access......
For the second part you are finding the Monday of the relevant week, hence you get the wrong month in some cases, the Thursday of the week (midpoint) should always be within the correct month so you can just add 3 to get that (-2 becomes 1), i.e.
=MONTH(DATE(YEAR(C2),1,1)-WEEKDAY(DATE(YEAR(C2),1,3))+D2*7)
I assume C2 is a date within the relevant year and D2 is the ISO week number
but probably better to have C2 containing the year, e.g. just 2013 and then you can use
=MONTH(DATE(C2,1,1)-WEEKDAY(DATE(C2,1,3))+D2*7)
I am trying to convert column with GMT hour to the specified time zones from the user.
I get an error when VBA attempts to subtract 18000 secs (GMT-5) from 01:00.
Selected_GMT = -18000
CellValue = "1/0/00 01:00"
New_Time = DateAdd("s", Selected_GMT,CellValue)
Is this error happening because VBA is unable to determine the hours before 00:00?
I have figured out the seconds for Selected_GMT, how can I use that to determine New_Time?
As ooo noted in a comment above, 1/0/00 is an invalid date code. However even if that was a typo in your question, the fact that the date uses a 2 digit year code begs the question "WHICH year 00?" Apologies if you already know this, but below I've extracted a recap of how Excel dates work from something that I've written elsewhere. The relevant part is "Day Zero And Before In Excel"; if the "00" actually represents *19*00 in the cell (as it will if you've just punched in "01:00 as the cell entry), you're going to run into problems subtracting from that. In which case, perhaps explicitly enter the date and time (perhaps using the current date) but hide the date component using formatting):
Excel uses a "date serial" system in which any date that you use in
calculations is represented as a positive integer value. That integer
value is calculated from an arbitrary starting date. Adding whole
numbers to a specific serial date moves you forward through the
calendar a day at a time, and subtracting whole numbers moves you
backwards... as long as you don't go past the starting date of the
serial number system and end up with a negative value. Times are
represented as fractions of a day; 0.25 for 6am, 0.5 for noon, 0.75
for 6pm and so on.
Excel Dates
In the case of Excel for Windows, the starting date is 1 January 1900. That is, if you enter the value 1 into a cell in Excel
and format it as a date, you'll see the value as 1 January 1900. 2
will be the 2nd of January 1900, 3 the 3rd of January, and so on. 367
represents 1 January 1901 because Excel treats 1900 as having been a
leap year with 366 days. In other words, every full day that passes
adds 1 to the serial date.
It's important to remember that the above relates to Excel only, and
not to Access, SQL Server or other database products (or Visual Basic,
for that matter). In Access, for example, the range of valid dates is
1 January 100 to 31 December 9999, the same range that can be stored
in a VB or VBA variable with a Date data type.
Excel And The Macintosh
Macintosh systems use a start date of 1 January 1904, neatly bypassing the 1900 leap year issue. However that
does mean that there's a 4 year discrepancy between the serial date
values in a workbook created in Excel for Windows, and one created in
Excel for the Mac. Fortunately under Tools -> Options-> Calculation
(on pre-2007 versions of Excel) you'll find a workbook option called
1904 Date System. If that's checked, Excel knows that the workbook
came from a Macintosh and will adjust its date calculations
accordingly.
Excel Times
As noted in the introduction, times are calculated as a
fraction of a day. For example 1.5 represents noon on 2 January 1900.
1.75 represents 6pm on 2 January 1900.
(Snipped a bit about the leap year bug in 1900)
From 1 March 1900 onward Excel's dates are correct, but if you format
the number 1 using the format dddd, mmmm dd, yyyy you'll get the
result Sunday, 1 January 1900. That is incorrect; 1 January 1900 was a
Monday, not a Sunday. This day of week error continues until you reach
1 March, which is the first truly correct date in the Excel calendar.
Day Zero And Before In Excel
If you use the value zero and display it
in date format you'll get the nonsense date Saturday 0 January 1900.
If you try to format a negative value as a date, you'll just get a
cell full of hash marks. Similarly if you try to obtain a date serial
number using Excel functions like DateValue, you can only do so for
dates on or after 1 January 1900. An attempt to specify an earlier
date will result in an error.
The 1904 (Macintosh) system starts from zero. (1 January 1904 has a
value of 0, not 1. Excel's on-line help describes the Mac system as
starting from January 2, but that's probably easier than explaining to
users why a serial date value of 0 works on the Mac but not Excel.)
Negative numbers won't generate an error, but the number will be
treated as absolute. That is, both 1 and -1 will be treated as 2
January 1904.