Removing time element of Long Date Format - excel

I have a list of data within the last three years, but all the dates have different times on it. I am trying to write a macro that will delete all the times. I tried changing the format of the cell but it didn't work.
EX. the list looks like:
10/12/2011 08:41 PM Eastern Time
10/12/2011 08:41 PM Eastern Time
10/12/2011 08:41 PM Eastern Time
10/12/2011 08:41 PM Eastern Time
10/12/2011 08:41 PM Eastern Time
10/12/2011 08:41 PM Eastern Time
10/12/2011 08:41 PM Eastern Time
10/12/2011 08:41 PM Eastern Time
And I need to delete the 08:41 PM Eastern Time or equivalent from each. All the times are different though. Any thoughts?

If actually date format, try =INT(A1) then format to suit.
This should cover either text or time format:
=IF(CELL("type",A1)="l",LEFT(A1,FIND(" ",A1)),INT(A1))
or even:
=TEXT(IF(CELL("type",A1)="l",LEFT(A1,FIND(" ",A1)),INT(A1)),"mm/dd/yyyy")
if the output is to be formatted mm/dd/yyyy.

If the field is an excel date and not plain text, you can use the trunc function. It should trim the time portion off.
=TRUNC(A1)

Why not simply:
=Left(A1,10)
Assuming all dates look the same (mm/dd/yyyy) format

Just in case it isn't always the first ten characters (examples: 1/1/2011 or 3/14/12), you can use this formula. Be sure to format the cell as date:
=--LEFT(A1,FIND(" ",A1)-1)

Not sure why this is not mentioned in any of the answers as its by far the fastest and easiest way to do this. You can use the DATEVALUE to convert the dates from text to an excel date if they are not already in an excel date format.
Once the date is in a number format (eg 42753.597534 which excel recognizes as January 18, 2017 2:20:27 PM): Excel equates dates to numbers and 1 is equivalent to 24 hours(1 day), while anything less than 1 is used for time. You can use ROUNDDOWN(A1,0) which will strip any non-integer part of the date which implicitly gets rid of the time (turning the above number into 42753 or January 18 , 2017.

Related

How to create a statement to count total of date and time

I have data in two separate columns like this
But how can I count how many rows are occurring within say a window of 6 AM to 10 PM and outside a window of 10:01 PM to 5:59 AM?
The first column cells are formatted as General. The second column cells are custom h:mm:ss
Fuller View
Here I have a formula to count how many times "Mon" comes up in the left column
=COUNTIF($D:$D,"*"&$K5&"*")
And this is what I have when I try to combine the two to determine how many "Mon" entries were between 06:00 AM and 10:30 PM
=COUNTIFS($D:$D,"*"&$K5&"*",$E:$E,SUMPRODUCT((E2:E119>=M4)*(E2:E119<N4)))
but I get a fat 'ol zero
Yet if I run
=SUMPRODUCT((E2:E119>=M4)*(E2:E119<N4))
I get 116 as a return for the amount of times that a cell is between 06:00 AM and 10:30 PM
So BLUF - I want to count how many times a row has "Mon" and a corresponding time between 06:00 AM and 10:30 PM then I can replicate it for the rest of the days of the week.
New update-dtd 10/11/2022
Right now I know that there are 4 instances where Tuesday had after-hours calls:
Instance one was at 5:59 AM on the 11th
Instance two was at 5:57 AM on the 11th
Instance three was at 10:39 PM on the 11th
& Instance four was at 10:36 PM on the 11th
but with the formula of =COUNTIFS($D:$D,""&$K7&"",$E:$E,">="&$O$5,$E:$E,">"&$P$5)
I am only accounting for 2 of those instances - the 10:39 PM and the 10:36 PM instance (found this out by testing/removing the values in the cells to see what changed the total).
How would I capture the times that are between midnight and 05:59 AM, to include 5:59 AM?
#ScottCraner solved this with
=COUNTIFS($D:$D,""&$K5&"",$E:$E,">="&M4,$E:$E,"<"&N4)

How we can extract Day, Date, Time in Excel which is in the format of following Fri Aug 07, 2020 05:12 UTC?

Long Date
Fri Aug 07, 2020 05:12 UTC
Day | Date | Time |
Friday | 07:10:2020 | 05:12 |
to get the date from that string use:
=--MID(A1,5,LEN(A1)-8)
Put that in three cells. Then format the cells:
day cell: dddd
Date Cell: dd\:mm\:yyyy
Time Cell: HH:MM
You could use the following to put the text string into just a date time format that excel understands:
=DATEVALUE(RIGHT(LEFT(A1,LEN(A1)-4),LEN(A1)-8))
The above will not be affected by number of digits for year, day or hour; only that the bit it is using has 4 chars at the front (Fri and space) and 4 at the end (space and UTC).
Since you have two digits for both day and hour, this could be simplified with using MID, like:
=DATEVALUE(MID(A1,5,LEN(A1)-8))
To extract a date from a text string representing a date, you can use the DATE function e.g. =DATE([year],[month],[day]).
To get those parts from a text string you can use =MID([input text string], [start position], [number of characters]). So you could do MID for each component (year, month etc) needed, then put the results through the DATE function.
Date formats in Excel are distinguished between what is stored and what is displayed.
What is stored depends on your excel settings.
What is displayed depends on your excel settings as well as your "regional and language options" or equivalent settings in your computer's operating system.
To change what is displayed, set a custom format (ctrl-1, first tab, last list item) to something like Ddd Mmm dd, yyyy hh:mm.
Otherwise regional and language options, and program settings, can override how the date is shown (which can be important if you are sharing workbooks, especially with unknown future users).
Is the input UTC or do you need to convert?
If you need to convert, do you have a fixed offset in hours? If so, it is a simple formula. For example: =A1+3/24 for UTC-3 hours.
To change what is stored, first understand whether the number stored represents the number of days since 1 Jan 1901, or 1 Jan 1904, or some other convention (such as 1 Jan 1970).
Then decide if you want to store it as a date or a text string.
Then decide if you want to store it as 3 copies of the same value (each displaying a different aspect: day, date, time) or if you just want each value to be its own part not the whole date "hidden" and the display set.
To store it as a text string, use =TEXT(A1,"Dddd"), =TEXT(A1,"MM:DD:YYYY") and =TEXT(A1,"HH:MM").
Watch out for 24 or 12 hour time: the difference is whether "AM/PM" is appended. Your input is likely 24h time but check another example from the dataset to be sure.

Excel multiple if function

I am facing the following issue, at the moment.
I would like to know if a value matches with a field. This field contains the following information:
9/4/2015 12:00:00 PM
Month/Day/Year hh:mm:ss
Now I want to compare my values with the field mentioned above.
My values are: Day and Month.
My idea is to create one term and just change the values in the term
every month (for the report).
e.g.
IF Month = 10 and Day = 27 write Yes in a field. If not write No.
The problem is that a day or a month can have either two or one number:
9/4/2015 12:00:00 PM
10/25/2015 12:00:00 PM
1/12/2015 12:00:00 PM
12/1/2015 12:00:00 PM
Any ideas?
Thanks in advance.
The following forumula would do it without using VBA, comparing the value in A1 to a specific day and month using IF and SUMPRODUCT:
=IF(SUMPRODUCT(--(MONTH(A1)=10);--(DAY(A1)=27));"Yes";"No")

Excel: auto format time of day when inputting time

I'm inputting time in and time out logs for my business to calculate the total hours worked by individual contractor companies visiting my site. We operate from 6:30am to 5pm. Excel automatically formats the data as AM, except for 12:00-12:59 which it correctly assumes is PM. I need excel to recognize that any time between 12:00 and 5:00 is PM. This will save me from having to type PM for each "time out" which over the course of a year will save me hours.
I'm not really sure how to do this. I'm guessing an if/then macro?
You can change the cell format as shown below:
when you type 17:00 is correctly displayed as 5:00 PM
I just use military time to get around this problem. 5 PM is not 5:00, but rather 17:00. Then you don't need to put in a PM or anything. Note: This is just for inputting the time. You can still display the time as 5:00 PM or whatever by formatting those cells or columns as the 'Time' type.
1 PM = 13:00
2 PM = 14:00
3 PM = 15:00
4 PM = 16:00
5 PM = 17:00
6 PM = 18:00
etc.

Calculate time in all countries for fixed time in one of them

I have table with all countries GMT/UTC timezones, I need to see what time is in the rest of the countries when in USA is 11am-3pm
Not on particular date just know the difference in time.
I did my calculation like that I -5 GMT in USA and time is 11am then in Russia for example is +4 GMT.
5+4+11=20pm in Russia when USA is 11am, this works with countries that have + GMT zone but ones that have minus it shows wrong time.
I am working in Excel; please help me with advice on how to do it.
I did it already for the +gmt timezones and yes I have times for cities in big countries too; it was not my question.
How can I find out what time zone is in country with -11gmt when in country with +8gmt is 11am?
Someone know?
E.g. I work with dates like this in Excel. I set type of cell data to date and put
1/1/11 4:30 (+4:30 gmt)
1/1/11 1:00 (+1:00 gmt)
Now I have a date e.g. 1/20/11 11:00 (11 am on imaginary date); all I need to do is
"1/20/11 11:00 AM" - "1/1/11 4:30 AM" = "1/19/00 10:00 AM" at (0 gmt)
10am I don't really care about date in this case just time. I cannot think right now how I gound precise time but it seems somehow work without even putting +8 gmt in there...
Anyway solution should look something like that.
What about countries that have more than one time zone?
11am in the USA....where? West coast (PST) or east coast (EST)?
How do you take into consideration daylight savings time?
There are a lot of things to consider to do time conversions correctly.
I personally wouldn't keep a table with country and hour conversions, but two tables. One with timezones and hours from GMT time. And then another one with city names and timezone mappings. This way instead of converting from USA to Russia, you would be converting from New York to Moscow.
I did do a quick search on timezones in excel, and I found this article. I hope that it helps.

Resources