Excel DATEVALUE函数独立于国际设置 [英] Excel DATEVALUE function independent of international settings

查看:223
本文介绍了Excel DATEVALUE函数独立于国际设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Excel工作簿中,我从另一个(文本)源中复制一些日期信息。
为了能够使用这些日期的计算,我使用函数DATEVALUE。



示例:单元格A1包含文本 2014年2月20日,单元格B1包含公式 = DATEVALUE(A1)
这样可以预期:我得到了1-1-1900之后的天数,我可以用任何可以想象的日期表示法来显示。

到目前为止没有问题。即使这不是英文的典型日期表示法,DATEVALUE也可以认定二月作为月份名称,并据此行事。



现在,当我在具有不同国际设置(Windows 7:控制面板 - >区域和语言 - >格式)的计算机上打开此工作簿时,单元格B1给出 #VALUE 错误。只有当我将A1中的文本更改为 20 februari 2014 (荷兰语日期字符串,根据该PC上的国际设置),DATEVALUE给出与以前相同的结果。 / p>

显然,DATEVALUE使用国际设置将字符串转换为日期。



有没有办法为了防止这种情况,请按以下说明:




  • 使Excel了解A1中的字符串用英语书写,
    PC上的国际设置恰好是

  • ,并将此字符串转换为日期,随后可用于计算?


解决方案

您可以尝试以下公式:

  = DATE(RIGHT(A1; 4); MATCH(MID(A1; 4; 3); {Jan;Feb;Mar;Apr;May;Jun ;Aug;Sep;Oct;Nov;Dec}; 0); LEFT(A1; 2))

日期承认参数总是在顺序年,月,日



我承认日期值始终为2位数。



如果您不介意写入月份。在一个范围内,您可以获得更短的公式。



根据您的区域设置,您可能需要替换字段分隔符; by,


In my Excel workbook, I copy some date information from another (text) source. To be able to do calculations with these dates, I use the function "DATEVALUE".

Example: cell A1 contains the text 20 february 2014, cell B1 contains the formula =DATEVALUE(A1). This works as expected: I get the number of days since 1-1-1900, which I can display in any date notation imaginable.
No problem so far. Even through this is not a typical date notation in the English language, DATEVALUE recognizes february as the month name and acts accordingly.

Now, when I open this workbook on a computer with different international settings (Windows 7: Control panel -> Region and language -> Formats), cell B1 gives a #VALUE error. Only when I change the text in A1 to 20 februari 2014 (Dutch date string, in accordance with the international settings on that PC), DATEVALUE gives the same result as before.

Apparently, the DATEVALUE uses the international settings to convert from the string to a date.

Is there some way to prevent this, in order words:

  • to make Excel understand that the string in A1 is written in English, regardless of what the international settings on the PC happen to be
  • and to convert this string to a date, which can subsequently be used in calculations?

解决方案

You can try this formula:

=DATE(RIGHT(A1;4);MATCH(MID(A1;4;3);{"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"};0);LEFT(A1;2))

Date admits arguments always in the order year, month, day

I admit that day values are always 2 digits.

If you dont mind to write the months abrev. in a range then you can get a much more shorter formula.

Depending on your regional settings you may need to replace field separator ";" by ","

这篇关于Excel DATEVALUE函数独立于国际设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆