How to input a date in custom format in Excel? - excel

I have a cell with this value: Sat 24 Jan 2009 01:23:12
I defined a custom date format: jjj jj mmm aaaa hh:mm:ss
.but I can't do arithmetic on this date cell. For example I can't do "CELL + 1 hour"

to add an hour to time just add +(1/24) to the formula or =cell+(1/24) in a new column

Excel doesn't exactly understand a text as a date when a custom formatting is created, so the way you described it in your question is not really going to work (unless someone actually knows a way to do that). I'd suggest using a helper formula that will work for the specific format that you have:
=SUBSTITUTE(SUBSTITUTE(MID(A1,5,20)," ","-",1)," ","-",1)*1
If you omit the *1 I have at the end, you should see the text I'm using before multiplying by 1 (that's where Excel attempts to convert the text to number, which is a date format that Excel can understand).
The above should give you a number with some decimals. Format it as date, with the formatting of your choice and you should be good to go. I used dd/mm/yyyy hh:mm:ss and got this:
The MID basically removes the weekday part, and the two SUBSTITUTEs replace the first 2 spaces with a dash each, and that's something Excel can understand as datetime.

Related

Non-Typical Date format for excel

I need to convert a date format into a date format that excel understands. This format I'm using is an export from a military system that spits the date out in a "military style" date format.
I need this: 011000Z OCT20 to equal 01-OCT-20.
The original format is this: DD HHMM(time Zone) MMM YY; so 01 1000Z(GMT Time) OCT 20
How can I make Excel recognize this as a date?
Currently, I'm using the Text to column feature to separate out the date, dump the time, then concatenate the multiple column into a date format. I then have to copy paste the new text into a date formatted column.
I have over 300 rows of date to go through, and its usually 100 rows weekly.
MACROS are not allowed on my systems. So this will have to be formulas.
Just looking for a more automated / simplified method that can keep up with the system exports.
Thanks everyone!!
Frank
If one has TEXTJOIN:
=--TEXTJOIN("-",TRUE,FILTERXML("<a><b>"&SUBSTITUTE(A1," ","</b><b>")&"</b></a>","//b["&{1,4,5}&"]"))
Depending on one's version this may require the formula to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
then format the cell: dd-mmm-yy
=--REPLACE(A1,3,5,"")
will remove the time portion and convert to a date.
You'll need to format the result as a date

Change date in excel

I am trying to change the date format of my cells in excel to another date format. Currently it is in this format: apr, 10, 2017 01:58:24 PM. I would like to have it in a normal format like dd-mm-yyyy without the time, but I can not get it to work with the formatting in excel.
Thanks in advance,
Kester
You could use this:
=(MID(A2,FIND(",",A2)+2,FIND(",",SUBSTITUTE(A2,",","#",1))-FIND(",",A2)-2)&"-"&LEFT(A2,FIND(",",A2)-1)&"-"&MID(A2,FIND(",",SUBSTITUTE(A2,",","#",1))+2,LEN(A2)))*1
Which is basically a bit of string manipulation (and some substitution of , to # to help) to put it in the generic format 'd-m-y h:m:s t', which excel understands, then multiply the string by 1 to force into a number (in this case 42835.58222); which you only have to format as date (important!):
Edit: Per comments, the first comma doesn't actually exist, so the revised formula:
=(MID(A2,FIND(" ",A2)+1,FIND(",",A2)-FIND(" ",A2)-1)&"-"&LEFT(A2,FIND(" ",A2)-1)&"-"&MID(A2,FIND(",",A2)+2,LEN(A2)))*1
With data in A1, in B1 enter:
=DATE(MID(A1,10,4),MATCH(LEFT(A1,3),{"jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"},0),MID(A1,6,2))
and apply desired formatting:
(this results in a genuine Excel date that can be used in sorts, calculations, etc.)(this assumes that the day field is always two digits)(if your month list is in a language other than English, edit the month list)

Difference between two date columns formatted as General

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].

Format code for a date with time zone in excel

I have date value with a time zone.
24 Nov 2005 GMT+05:30
What is the format code for this custom format in Excel?
I tried dd MMM yyyy with z,zz,zzz, and Z but Excel ignores those options.
Not sure if possible. I've just gone through every letter in custom format cell and nothing looked right.
What I would suggest is maybe splitting it up into a few cells and then bringing them all together.
In the first column (A1) you could have the date, formatted how you like (dd mmm yyyy).
Second (B1) you could have the time before you account for the different timezone (formatted how you like, i.e. hh:mm:ss.
Third (C1) define if the timezone is ahead or behind with a plus/minus sign.
Fourth (D1) you could set the time difference (i.e. your example +5:30). Format the cell as h:mm.
Fifth (E1), enter the formula: =IF(C1="+",B1+D1,IF(C1="-",B1-D1)). Format the cell as hh:mm:ss.
Finally, (F1) there's two options for you. You can combine the date and time adjusted to the timezone, or you can combine the date, original time and include timezone.
The first option would be: =TEXT(A1,"dd mmm yyyy ")&TEXT(E2,"hh:mm:ss")
Second would be: =TEXT(A1,"dd mmm yyyy ")&TEXT(B1,"hh:mm:ss ")&"GMT"&TEXT(C1,"")&TEXT(D1,"h:mm")
This is the absolute best solution I could think of. Sorry if it's not what you asked for.

Convert number to YYYYMM

I have following numbers, which actually represent dates in the YYYYMM format:
201301
201302
201303
...
When I try to format the cells to date fields, Excel always overwrites the original dates and creates some crazy dates, that have nothing in common with the actual ones.
How can I bring Excel to convert it properly?
Excel (by default) uses the 1900 date system. This simply means that the date 1 Jan 1900 has a true numeric value of 1, 2 Jan 1900 has a value of 2 etc. These values are called "serial values" in Excel and it is these serial values that allows us to use dates in calculations. which was discussed here.
So that explains why your data reflects a different date when you try to format is as Date.
What you need to do then is to transform it into a complete readable date format Excel recognize.
As is, Excel will use its default Serial Value conversion.
If you have your data in starting in A1, enter this in B1.
=DATEVALUE(SUBSTITUTE(A1,LEFT(A1,4),LEFT(A1,4)&"-")&"-01")
Above formula will then create a valid Date that Excel can interpret and read correctly.
Result will be:
41275
41306
41334
When you format it as Date, it will equate to the 1st day of every month.
1/1/2013
2/1/2013
3/1/2013
You can just fix the formatting using Custom Format to get YYYYMM as seen below:
If your range is small enough (in the example all 2013) then no formula is required. Replace 13 with 13-, apply Text to Columns with Tab as the delimiter and at Step 3 choose Date and YMD.
You can use the DATE and LEFT/RIGHT functions.
Assuming that format is consistent (i.e. 4 characters for year, 2 characters for month), to convert cell A1:
=DATE(LEFT(A1,4), RIGHT(A1,2), 1)
This will assume the first day of the month for the date (I assume that's irrelevant for you). You can then format the cell as you want.
Can you use formula in Excel to solve this..
A sample formula is given below
=DATE(MID(CELLID,1,4),MID(CELLID,5,2), 1)

Resources