Format code for a date with time zone in excel - 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.

Related

Date format conversion in Excel

I have a list of dates, which seem to be in dd/mm/yyyy hh:mm format ( Ex - 12/13/2022 12:16 AM ) , which is incorrect. I need to change to mm/dd/yyyy hh:mm format.
I tried the formula =IF(H2="","",IF(DAY(H2)>12,DAY(H2)&"/"&MONTH(H2)&"/"&YEAR(H2),VALUE(DATE(YEAR(H2),DAY(H2),MONTH(H2)))))
but the result is #Value
You seem to be missing the point: a datetime format in Excel is a normal number, where 1 means one day, starting at the first of January, 1900.
Let me show how it looks on my PC:
As you can see, there are two ways to describe the thirteenth of December, 2022:
format dd/mm/yyyy : 13/12/2022 (European style)
format mm/dd/yyyy : 12/13/2022 (American style)
But as you can see below, the actual values are the same (44908 is the amount of days starting at January first 1900).
Doing calculations on this, like checking =DAYS()>12, has no meaning, because the days will be calculated from that 44908 number, not from the way it's displayed.
So, don't start formulas on that, just alter the way it's displayed (using cell formatting, as shown in my screenshot).

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

How to input a date in custom format in 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.

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)

Assemble a date and time concatenation that can be read by an hour and minute difference equation

4/27/2009 is in a cell with a Date format. It says "4/27/2009" (w/out the quotes of course).
In another cell I've got "2:30 PM" (again, w/out the quotes). Its underlying function is =TIME(HOUR(P6),Q6,0) where the hour is HOUR(P6) where P6 is a Custom format m AM/PM, and the minute is taken off a number formatted Q6, and I'm not concerned with secs., and the cell it resides in is formatted as Custom h:mm AM/PM.
Now how do I put them together in a third cell as "4/27/2009 2:30 PM" (w/out quotes of course) so that I can take a similarly constructed second value and be able to subtract one from the other and get a number of hours (nevermind minutes but I'll take those too)?
Thank you for any help.
Putting a formula in the third cell that adds the date cell and time cell should work. (A3=A1+A2). To calculate the difference you can use a subtraction (unsure) or a combination of TIME and the DATEDIF function.

Resources