I have some dated in this format "09-MAY-13 06.42.46.097127000 PM" and need to convert to this format "2013-05-09T18:42:47.132Z". my goal is to find out which happend earlier. I am not sure how to format these dates.
2013-05-09T18:42:47.132Z 09-MAY-13 06.42.46.097127000 PM
2013-05-08T20:56:55.821Z 06-MAY-13 03.22.09.129443000 PM
2013-05-08T20:51:45.287Z 06-MAY-13 03.03.22.975700000 PM
2013-05-08T20:55:34.719Z 06-MAY-13 10.40.55.924181000 PM
How I can do that??
I originally posted an answer which converted one of your formats to the other. I now see that you need to compare them, so you can convert this format in A2 to date/number values ....
09-MAY-13 06.42.46.097127000 PM
.....with this formula
=SUBSTITUTE(SUBSTITUTE(A2,".",":",1),".",":",1)+0
and this format in A3
2013-05-09T18:42:46.097z
....with this formula
=SUBSTITUTE(SUBSTITUTE(A3,"T"," "),"z","")+0
You can format the results how you like, leave as numbers or format as m/d/yyyy hh:mm:ss.000 or similar. you can now compare easily with a formula like
=B2>B3
or get the smaller or larger with MIN or MAX
If have a value of your original style in cell A1, place the following formula in a different cell:
=DATE((2000+MID(A1,8,2)),MATCH(MID(A1,4,3),{"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"},0),LEFT(A1,2))+TIME(MID(A1,11,2)+IF(RIGHT(A1,2)="PM",12,0),MID(A1,14,2),MID(A1,17,12))
Then, in that target cell, apply the following format:
yyyy-mm-ddThh:mm:ssZ
Please note the following:
This assumes that all of your months are 3 characters (JAN, FEB, MAR). Since your example was "MAY" (already 3 characters), I don't know with certainty how your other months appear. Longer month names complicate the formula a bit. I can help with this if you need it and don't know how to do it.
I couldn't find a way to force Excel to display fractional seconds in the context of such complex date/time formatting, even though your example showed seconds subdivided to the thousandths. Hopefully this isn't a deal-breaker. If it's necessary to display fractional seconds, you may need to handle this with a separate formula to display the result as text, independent of the formula above, which you can use for your calculations of which date came earlier.
To add to Joe's answer...
To get Excel to compare one column to the other you need to do the same sort of manipulation from the first column as the second.
That would look like
=DATE(LEFT(A1,4),MID(A1,6,2),MID(A1,9,2))+TIME(MID(A1,12,2),MID(A1,15,2),MID(A1,18,5))
Once you have a new column for each of these transformations it should be simple to have Excel compare them.
Related
I have two date rows. Both are formatted as dates. When I do a logic test to see whether the two dates, excel is not recognizing them as the same.
Here is a screenshot of the cells:
This is to confirm that both cell rows are formatted as date:
This is to confirm that the equality check row is referencing the right cells:
I'm stumped. Does anyone have any idea what's going on here? Thanks
If you have confirmed that both are actually dates, and not text masquerading as dates, then time is most likely the issue. Note that time is represented via the decimal such that .5 equals noon.
Assuming you just want to know if the dates match independent of time you can use
INT(G4) = INT(G6)
If you want to compare just the dates use:
=Floor(G4,1) = Floor(G6,1)
Format can mask the real cell value. Format both cells as General, then you can see the difference.
If a cell stays a "date" when it is formatted as General, then the cell is most likely text, not a date.
When formatted as General, you can clearly see if the number has any decimals, i.e. time on top of the date.
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.
I have a column of times in hhmmss format. What is a formula to convert them to an Excel Time value?
Note that they will not necessarily be zero-padded. E.g., 09:21:34 might appear as 92134 instead of 092134.
If cell A1 contains a time like "112345" then the most elegant conversion formula is:
=--TEXT(A1,"00\:00\:00")
A perhaps more understandable formula is
=TIME(A1/10000,MOD(A1/100,100),MOD(A1,100))
Note that both of these work regardless of whether the time is zero-padded.
So my friend has this template he got from his boss, it's got a bunch of dates and times and other data. He told me he created a new workbook and copied everything from the template to this new workbook and then he modified the dates. The date and time listing he copied from another file.
So this is where the problem occurs, when he's done copying, one entire column resulted with #VALUE! instead of expected result w/c would be in yy/ww format. The formula is written below:
=MID(N2,9,2)&"/"&IF(LEN(WEEKNUM(N2,1))=1,"0"&(WEEKNUM(N2,1)),(WEEKNUM(N2,1)))
Inside N2 is 26/08/2014 1:27 PM. So I googled a bit and found out that WEEKNUM doesn't work for text-style date and time. Should only work with serial numbers, if I understand it correct. I checked the N column (which was all copied from another file) and they were all in text. But when I checked the template, the dates were also all in text style. So how the formula worked with the template but not with the new workbook? (I'm assuming that every text in every cell is aligned to the left, dates in both new workbook and the template are both aligned to the left.)
I told my friend that the N column should be in date format so I suggested him this formula:
=(DATE(2014,8,26) + TIME(13,27,0))
And finally it worked. But his and my concern would be that we can no longer just copy and paste the dates but manually input every date within the formula. But there's just too many dates and it would take a long time to finish.
Any way around this?
UPDATE:
I just noticed something. The format of the dates copied is dd/mm/yyy h:mm AM/PM. When I checked on the column where all the #VALUE!s are spawning, there are exceptions. I actually found 3-4 cells that are normal.
The date is: 02/10/2014 3:49 PM and the result with using the formula is 15/49. I'm wondering, could it have been with how the dates are typed in? Or rather copied in? Like, should the date format be in mm/dd/yyyy instead of dd/mm/yyyy?
Used evaluate formula and it said that N2 contains a constant.
The WEEKNUM function works with dates as text while it can implicitly convert the text to date. Example:
Input '31/03/2015in A1 and =WEEKNUM(A1) in B1. Input '03/31/2015 in A2 and =WEEKNUM(A2) in B2. Note the leading ' before the dates. They will convert the inputs to text. One of them will work, one will not. This will indicate which is your default date format dd/mm/yyyy or mm/dd/yyyy.
You say both Excel are English but there is a difference in default date format between GB English and US English unfortunately.
So if the dates are text in dd/mm/yyyy format and your default date format is mm/dd/yyyy, you can't simply copy them into your Excel and work with them. You have to change them ever to mm/dd/yyyy first. Ever, because even the values which seems to work are mostly wrong. WEEKNUM with the text 09/11/2015 will work even with default date format mm/dd/yyyy. But it will implicitly convert the text to September 11. 2015 while with dd/mm/yyyy 09. November 2015 was meant.
Best solution ist not to use dates in text format. If your friend's boss had used date values instead of text then copy&paste would work. But because he had not, you have to convert the formats in a helper column now. Try
=MID(N2,4,2)&"/"&LEFT(N2,2)&"/"&MID(N2,7,999)
copied down in a helper column.
I have two columns in Excel, formatted as General - with this data:
Column A Column B
11/2/2014 9:12:27 AM 12/3/2014 2:00:00 AM
How can I find the difference in hours between them, if they are formatted as "General" and not "Date"?
Thank you for any advice,
Mark
I assume that means these are actually text formatted datetimes - you can test by trying to change the format, e.g. try to change to "Number" - if nothing changes theses are text values.
You can still subtract, though, if the datetimes are in a valid format for your region.
Try using a simple subtraction like
=B1-A1
custom format result cell as [h]:mm
I get the result 688:47 (which assumes that the first timestamp is 11th Feb not 2nd November)
Please try:
=VALUE(B1)-VALUE(A1)
custom formatted as[HH].