How to create a consistent range of dates in excel? - excel

I have a combination of two reports into a master file. I'll be eventually transforming the data into a more readable format, but I have a date column that has two different types of date formats:
(yyyy-mm-dd & mm/dd/yyyy)
Is there a formula I can use to convert this so every cell reads: mm/dd/yyyy?
I know I can do it via text-to-columns, but that will take a bit longer than I'd like.
I will repost the question if it only can be done via VBA, but I figure there may be a way to just complete it via one formula and an auto fill.

You can probably just use:
=DATEVALUE(A1)
And copy it down. You can then format the date to whatever format you like.
DateValue() Takes a date stored as a string and converts to excel's date type.

Related

Comparing dates coming from different files in Excel

I am trying to link two Excel files and compare the values from first one in the second one, but I have a problem at some point.
So the date 28/07/2021 comes from the other file (which is call 3WLA). I had to use the function TEXT(..., "dd/mm/yyyy") otherwise it displays 44405 which is an other form of the date. Now I want to compare this date with other ones but it doesn't work as showed in the pictures below.
The picture shows the comparison of two dates coming from the other excel file 3WLA (still using the function TEXT(..., "dd/mm/yyyy")). We clearly see that there is a problem as it should display TRUE. In the same way, when I compare a date from 3WLA (i.e. using TEXT(..., "dd/mm/yyyy")) with a date random in my file it give me the following
where 28/07/2021 is given by = TEXT('[3WLA.xlsx]Block-First-Fix'!$AM$1,"dd/mm/yyyy") and 29/07/2021 by = 29/07/2021
chris neilsen already gave you the answer in the comments.
To clarify further: The text "29/07/2021" and the date formatted to look like "29/07/2021" are different data types. To help with this MS Excel automatically formats numbers and dates to be aligned to the right and normal text to be aligned to the left
In B1 you can see that the date has been formatted in the same way as per the formula in A2, but since the output in B2 is of the text data type, the two are not considered the same.
You can use the formula DATEVALUE to convert from text to date serial number. (Read more about date serial numbers here).
If your texts with dates are too different from your local settings date formats, DATEVALUE might not give you correct results. In that case use DATE function in combination with some text functions such as LEFT, MID, RIGHT
You can format the cell to make the date more readable using either the number formatting field or the dropdown from the ribbon

Doing calculations in excel with Datetime format including milliseconds

I have this column in excel. The format is dd/mm/yyyy hh:mm:ss.SSS where SSS is milliseconds.
How can I make calculations such as subtracting two cells from each other? I keep getting an incorrect format error but I cannot find a format that includes date and time with milliseconds.
I am able to change the notation of the DateTime value but not split it into two cells.
Comments up above will suggest the built in test to columns method which works really well. Scotts tip about the third step is imperative. Jeroen's comments is using the DATEVALUE function which can be picky and somewhat dependent on your system settings. There is a third choice of using DATE. Jeroen's formula already does most of the work but needs a little tweaking. The nice part of DATE is it is not picky nor reliant on system settings.
Important tidbit of info. Excel stores dates as an integer with 1 representing 1900/01/01. Time is stored as a decimal which represents percentage of a day. So 0.5 is 12:00 noon. Also 24:00 is not a valid time for excel but will still work with some functions.
The DATE function looks for 3 arguments to be passed to it. Year, month, and day in that order. So it is just a matter of pulling the applicable parts of your timestamp as a string out and placing them in the right location. There is a Similar function for TIME.
Let assume one of your timestamps is located in C3
in D3 you can place the following formula to convert the date from text to an excel date:
=DATE(MID(C3,7,4),MID(C3,4,2),LEFT(C3,2))
In E3 you can place the following formula to convert the time from text to an excel time:
=TIME(MID(C3,12,2),MID(C3,15,2),MID(C4,18,6)
To get the information together its simply D3+E3. however if you want to place the whole formula in one cell and avoide helper columns, the formula would look like:
=DATE(MID(C3,7,4),MID(C3,4,2),LEFT(C3,2))+TIME(MID(C3,12,2),MID(C3,15,2),MID(C4,18,6)
Now that the time in in excel format you can perform operations on it, apply formatting to make it look like you want, and use various excel functions with it.

Recover pasted date from Excel which transforms it to an integer like 41884 using Excel or R

Dates in excel were pasted as values in a data set I received. The original format was:
9/2/2014
The pasted format was:
41884
I need to recover these dates either within Excel or using R. Normally integers are time since the Linux epoch (1/1/1970) or another origin. I have not been able to make sense of this data format, however.
41939 is 10/27/2014
41974 is 12/1/2014
and so on.
If you enter "1" in a cell, and format that as date in Excel, you'll get 01/01/1900. It increments one day per integer from there, so you can deduct your actual date from that point no?
If you want to use excel try setting the cell format to Date, the number is the amount of days since 1899-12-31 if that helps you in R.

How can I transfer a date format like 2014/02/13/19:57:00 to an excel readable date format?

I have tried and change 2014/02/13/19:57:00 to 2014/02/13 19:57:00, but excel still cannot detect this as readable date format so I cannot change to another date format in excel. I have a whole column of date like this one.
So what can I do in excel?
Thanks.
You should be able to use something like this:
=SUBSTITUTE(A1,"/"," ",3)*1
This replaces the 3rd occurrence of / and replaces it with a space. The *1 then tells excel to convert it into a number (if possible). Formatting the result as date time should give you the datetime you are looking for.
If for some reason that doesn't work, this formula can be used instead:
=(DATE(LEFT(A1,4),MID(A1,6,2),MID(A1,9,2))+RIGHT(A1,8))*1
That one takes bits of the date and sticks the time. Again, format the cell as datetime.

Converting a string to a date in a cell

I have 100.000 rows of data in Excel. Some of the fields are dates, but the fields in Excel are as text. I need these fields in number format including both dates AND time (e.g. 21.10.2011 13:10:50). Formatting the cells doesn't work because that doesn't change the datatype. I can pick out the date and time with formulas but not get them in the same cell.
So what I am looking for is the formula to calculate the number representation of a date (the one you see if you format a date as a number).
Have you tried the =DateValue() function?
To include time value, just add the functions together:
=DateValue(A1)+TimeValue(A1)
To accomodate both data scenarios you have, you will want to use this:
datevalue(text(a2,"mm/dd/yyyy"))
That will give you the date number representation for a cell that Excel has in date, or in text datatype.
I was struggling with this for some time and after some help on a post I was able to come up with this formula =(DATEVALUE(LEFT(XX,10)))+(TIMEVALUE(MID(XX,12,5))) where XX is the cell in reference.
I've come across many other forums with people asking the same thing and this, to me, seems to be the simplest answer. What this will do is return text that is copied in from this format 2014/11/20 11:53 EST and turn it in to a Date/Time format so it can be sorted oldest to newest. It works with short date/long date and if you want the time just format the cell to display time and it will show. Hope this helps anyone who goes searching around like I did.
The best solution is using DATE() function and extracting yy, mm, and dd from the string with RIGHT(), MID() and LEFT() functions, the final will be some DATE(LEFT(),MID(),RIGHT()), details here

Resources