Format code for a date with time zone in excel

隐身守侯 提交于 2019-12-19 17:28:09

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/26610751/format-code-for-a-date-with-time-zone-in-excel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!