I need to remove the seconds date part from my Excel DateTime field that looks as follows:
7/8/2014 4:17:59 PM I tried to format the cell to : mm/dd/yyyy hh:mm
This displayed the cell in the correct format, but it hasn't altered the actual value for the cell. When I compare a field with the value mentioned above with another field that has the same value but missing the second, Excel shows them as different values.
Example:
Cell 1: 7/8/2014 4:17 PM (True value: 7/8/2014 4:17:59 PM)
Cell 2: 7/8/2014 4:17 PM
Are Not Duplicates according to excel.
How can I remove the seconds part from that datetime completely?
03 Answers
This might be late but I just had the same issue and solved it with the following formula:
=TEXT(A2,"MM/DD/YYYY HH:MM") Where A2 is the cell containing the timestamp with seconds
Alternatively this should also work with AM/PM
=TEXT(A2,"MM/DD/YYYY H:MM AM/PM") Using the text formula is absolutely the right way to remove the seconds. The issue is that leaving the field as text causes sorting and calculations to fail. So solve this, you can use the following formula to convert back to a datetime in one step.
=DATEVALUE(TEXT(A2,"MM/DD/YYYY"))+TIMEVALUE(TEXT(A2,"HH:MM")) This may help: (assuming your date is in A1)
=A1-SECOND(A1) This will, in another cell, put the same value, with seconds set to 0.
1