Suggest me to customize excel with date formats - excel

In the image attached, I need employees to manually enter login and logout times in the format (HH:MM AM/PM) only. And In the column E I need a formula to calculate hours and minutes of duration in between.
I have tried with =text(D2-C2,"h:mm") formula and when I applied the same to all the columns, they're updating with existing empty cells and resulting 00:00 in the E column.
I only need to update column E only when C and D column values are updated.
Can someone please help me in this regard? I need time frame as 12Hour format.

You can use =IF(AND(C1<>"",D1<>""),D1-C1,"") in your No Of Hours column to calculate only if Log In Time and Log Out Time are filled.
For formatting, you can use Custom Format - h:mm for the No Of Hours column.

1, Try not to convert real time to text.
Use this formula in F2 then fill down. =E2-D2+AND(E2<D2, E2>0) This should also work if the shift spans midnight.
Use this custom number format hh:mm_);;; on the cells.
Example:

Related

Converting month number from full date cell into text month in Excel

So I have a pretty long column with name dates and hours, like this:
14/01/2017 03:30
(They are DD/MM/YYYY HH:MM)
I need to get the month number and show it as text, like January, February, and so on.
If I format the destination cell as 'MMM' all the column cells show January even if the given month is 2, 3, or let's say 12. I also tried the formula =TEXT(L2,"mmmm") (since the given info come from column F.
Any ideas?
sounds like your date and time are stored as text and not in excels serial date format. You can test this by changing the format of the cell to general and seeing if anything happens if nothing changes then its text. another way would be to use the formula =istext(A1) where A1 is a cell with a date in it.
Now ASSUMING you do have dates in text format, I would suggest converting them to excels date serial. There are numerous ways of doing this. I will show you one way.
This will strip each component of the text out and then recombine it. We will assume your date in is A1
Strip out the year
=MID(A1,7,4)
Strip out the month
=MID(A1,4,2)
Strip out the day
=LEFT(A1,2)
Now to recombine it:
=DATE(MID(A1,7,4),MID(A1,4,2),LEFT(A1,2))
That will give you the date in an integer format that excel can then turn around and display as needed.
In order not to lose the time component you should strip that part off as well and combine it with the date. Remember the date is an integer, and the time is everything after the decimal. Think of time as a fraction of a day.
To get time out use:
=RIGHT(A1,5)
and to convert it to excel time:
=TIMEVALUE(RIGHT(A1,5))
and to get the two together, simply add:
=DATE(MID(A1,7,4),MID(A1,4,2),LEFT(A1,2)+TIMEVALUE(RIGHT(A1,5))
The key part to this whole thing is you will need to format that cell to display what you want. you can either choose a preformatted style from the drop down menu, or you can apply custom formatting. Setting the custom format to MMMM should display just the full name of the month.
IF you actually need the text of the month and not just the format, then you could use the formula from your question:
=TEXT(<insert appropriate formula from above>,"mmmm")
Try using MID to get the month only, then TEXT():
=TEXT(MID(A1,SEARCH("/",A1)+1,2),"MMMM")

Excel IF + AND + Date range formula

I am looking to create and IF function that does the following.
There is a ton of data with one column containing dates. I want and if functions that labels each row according to the following.
If date falls between 0-30 days of todays date in the past then label "GOOD" (so if todays date is 21/09/2017 then it should be labelled as "GOOD" should it falls between the dates 21/09/2017 and 21/08/2017)
If date falls between 31-60 days of todays date in the past then label "FAIR"
If date falls between 61-90 days of todays date in the past then label "ATTENTION"
If date falls between 91+ days of todays date in the past then label "CLEARANCE"
Hope someone can help.
Many thanks
Use
=IF(TODAY()-A2<31,"Good",IF(TODAY()-A2<61,"Fair",IF(TODAY()-A2<91,"Attention","Clearance")))
Column D shows the difference between today date and cell date.
Alternative Answer
Use VLOOKUP to potentially ease your future formula maintenance. In an unused location, set up a table that has your break point ranges and associated return values. For this example I used the following:
Technically speaking column G is not required, but it can be easier for some people to read.
Now assuming your dates are in Column A, you can use the following formula in B2 copying down:
=TODAY()-A2
and in C2 use the following look up formula and copy down to get your desired results:
=VLOOKUP(B2,$F$3:$H$6,3,1)
now if you are not keen on generating the extra column for calculate the number of days, you can substitute that first formula into the second to get:
=VLOOKUP(TODAY()-A2,$F$3:$H$6,3,1)
place the above in B2 instead and copy down.
The following is an example of the first approach:
The main advantage to this approach is you can manipulate the lookup table easily changing breakpoints, wording of results etc easily without touching your formula (when done right)
if you have the potential for negative days, instead of returning an error, you could wrap the lookup formula in an IFERROR function to give a custom message or result.
=IFERROR(VLOOKUP(B2,$F$3:$H$6,3,1),"In the Future")
Assuming your data starts with A2, A3 and so on.. as below
Apply the below formula in B2 and drag down up to A8
=IF(AND(--TEXT(TODAY()-A2,"##")>=-1,--TEXT(TODAY()-A2,"#")<30),"GOOD",IF(AND(--TEXT(TODAY()-A2,"##")>=30,--TEXT(TODAY()-A2,"#")<60),"FAIR",IF(AND(--TEXT(TODAY()-A2,"##")>=60,--TEXT(TODAY()-A2,"#")<90),"ATTENTION",IF(--TEXT(TODAY()-A2,"##")>90,"CLEARANCE","FUTURE DATES"))))

Telling whether a date is before a particular time in excel

I have a spreadsheet with a date column in Column A. I want to have a column where it returns TRUE if the date is before September 2016. How do I do that?
I tried this code in Excel but it wouldn't work.
=if(A1="2017","TRUE",if(month(F1)<"September,"FALSE","TRUE"))
Can anyone help me correcting this one? Thanks
I'm assuming Column A has the actual dates (ex: 3/3/2017). So your if statement (if<"September") is trying to compare text against a date, which will give you an error.
Easiest way to do this is enter 9/30/2016 in a separate cell (for this example, say Q1). Then in your formula, simply use:=A1 < $Q$1 and drag that down. It should give you T/F for the dates.
If Column A is formatted as a date, it has to be compared with a date only. If not excel will give you unexpected results.
The DATE function in excel allows you to input data in date format with Years, Months and Days. The format is below,
=DATE(Years,Months,Days)
You can try the below formula,
=A1<DATE(2016,9,30)
and drag it down throughout the range.

Convert time (text) to Excel formatted Time

I have a list of durations in minutes used to log calls and I want to use Excel to format them and do some calculations. However, these are just exported as table and when I attempt to bring them into Excel, the cells won't format correctly.
An example below:
01:00 is entered as the number of minutes and seconds
However, when I try to use Excels cell format it turns it into
01:00:00 as in hours, minutes, seconds (hh:mm:ss).
Now I want to convert it to this as I also have the cost per minute which I then need to multiply by this time.
To clarify further as to why it needs to be in this format, is because i want to use the follow query to get the total cost per minute.
=(HOUR(H4)*60*I4)+(MINUTE(H4)*I4)+(SECOND(H4)/60*I4)
Can anyone help with how to get Excel to recognise this in mm:ss format.
Try this workaround. Format A column to be "text" type. Paste your data into column A. Format B column to be "custom" type, choose "mm:ss". Copy below formula down column B.
A1: 01:00
B2: =0+("00:"&A1)
B column will display and function as you desire.

Excel 2010: Hours and Minutes extract from hh:mm:ss formatted cell

For example:
I have a cell with the following value:
"1/11/1900 4:00:20 AM"
that will be displayed inside the cell as: "268:00:20" - meaning 268 hours, 00 minutes and 20 seconds (see the first image below).
EDIT:
Here is screen of how it looks like and the formatting of the cell
Here comes the Question:
What is the Excel 2010 formula (no VBA if possible!) to extract hours and to extract minutes from this cell, such as "268" should be shown for hours in a different cell and "00" (in this case) for minutes in another cell?
For clarification: the "268:00:20" is a duration of 268 hours and 00 minutes and 20 seconds.
What I'd like to get? In different cells, store the hours (268) and minutes (0)
The cell is formatted as Time (see the image below):
The value 1/11/1900 4:00:20 AM is really only a formatted number in Excel representing the number of days, i.e approx 11.167 in this case - I think Daniel's solution is not far off - using DAY and HOUR will work for values up to 31 days.......but for a more generic solution for hours use just:
=INT(A1*24)
and for minutes
=MINUTE(A1)
I would use something similar to what I used here. It's not really pretty for a solution but it works.
So, in your case what you do is:
Format the values in the time you want to, and copy/paste the value
(or column) into notepad. The clipboard copies and pastes what's visible
instead of the date/time value in excel.
In your worksheet, insert a
new column and format it as text. This will cause excel to accept
the values as is and not convert them into date time.
Copy everything from notepad and paste into the new column you just
formatted as text. You will get the values of the time as is in
excel.
From there, you can use a Text to column with colon delimited to split the time to get 3 columns: hours, minutes and seconds (and additional tip, in the split to column window, where you are asked about the format of the split columns, format all as text).
EDIT: Since it doesn't seem too obvious...
Column B is the original date/time.
Column C is the same date/time
formatted in hours, minutes and seconds only. Copy and paste column C
in notepad.
Format Column D as text, then copy the values in notepad
to the column. This gives you the time stored as text.
Column E to G is the split of column D, colon delimited.
You do not need any formulas at all. Just format the cell with this format [h]:mm:ss;#
Example below:
Say your date is in Cell A1 as shown:
Go to format options:
Then Under the Number Tab Select Custom. Then enter the above Custom time format into the box:
And your cell will end up as:
Or by formula you could do it using DateDif() with the formula =DATEDIF(0,A1,"D")*24+HOUR(A1)&":"&MINUTE(A1)&":"&SECOND(A1)
as shown below:
You will have to use Day and Hour formulas.
The Hours will return only the time part.
You will have to sum it with 24*Day. Maybe you will need to use Year as well, depending on what you want.
For the minutes, use Minuteformula.
If there's a start date and the desired date, you can use 24 * Days(DesiredDate, StartDate).
Just use Text To Column function under Data in the Menu Bar. Works really well for time that is more than 24 hours. I had a problem where the minutes and seconds were displayed inconsistently sometimes in 2 digits and sometimes in 1 digit eg. 268:1:13 or 541:12:3 or 671:45:30. In that case just select delimiter as ":" (vs Fixed Width option) and it will be able to display the Hours Minutes and Seconds in separate columns. Problem Solved!

Resources