在 MS Word 字段中显示日期差异
我有一份简历,希望在开业时自动更新我的年龄。那么,我应该在 MS Word 字段中插入什么公式呢?
像这样的东西:
{= {DATE} - {"01/01/1983"} }
I have an CV and would like to automatically update my age when opening. So, what formula should I insert in a MS Word field?
Something like:
{= {DATE} - {"01/01/1983"} }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这是处理 Word 字段代码的最佳网站之一 - http://www.addbalance。 com/usersguide/fields.htm - 那里有关于如何创建 +/- 日期的示例。
以下是根据 1 月出生月份和 1983 年出生年份进行计算的方法。
{IF{DATE\@"MM"} >= 01 { = {DATE\@"YYYY"} – 1983 \#" 00"} { = {DATE\@"YYYY"} – 1984 \#"00"}}
请注意,在一月份的情况下,此 IF 语句将始终为 true 并为您提供 =YEAR- 1983年。您可以使用另一个嵌套 IF 语句来检查当天,以进一步获得更准确的结果。
This is one of the better sites for working with Word field codes - http://www.addbalance.com/usersguide/fields.htm - and there are examples there on how to create +/- dates.
Here's how you would calculate based of a birth month of January and birth year of 1983.
{IF{DATE\@"MM"} >= 01 { = {DATE\@"YYYY"} – 1983 \#"00"} { = {DATE\@"YYYY"} – 1984 \#"00"}}
Note that in the case of the month of January, this IF statement will always be true and give you =YEAR-1983. You can use another nested IF statement to check on the day to further get more accurate.
我尝试过,但在Word字段中找不到与Excel中从另一个时间减去白天的方法相同的方法(比方说从今天03/21/2013开始,从1983年5月18日开始),这在Excel中很容易从白天(01/01)开始Excel 2013 中的 /1900)已被选为开始,此后每隔一天根据此参考进行计算,显示的详细信息仅是表示此结果的一种方式(完整日期、数字中的月份或其全名,甚至是Excel 的简单数字),可以通过右键单击单元格并选择类别单元格格式来切换(因为 01/01/1900 是 1,那么 05/18/1983 是 30454(...还有 00/01/ 1900 是 0!))。
为了回答最初的问题,我建议这样写:
请记住:
MERGEFORMAT 选项对于保持正确的格式很有用。
另外,对于那些不习惯使用 Word 字段的人:
这适用于 1983 年 5 月 18 日(我将 1 月 1 日更改为 1 月 1 日,以避免混淆):
I tried but could not find in Word fields the equivalent of the Excel way to substract a daytime from another one (let’s say 05/18/1983 from today 03/21/2013) which is easy in Excel since a daytime (01/01/1900 in Excel 2013) has been chosen as the beginning and every other day since is calculated according to this reference, the shown details only being a way of representing this result (full date, month in figures or its full name, or even the simple number of Excel), which can be toggled by right clicking on the cell and choosing the category cell format (since 01/01/1900 is 1, then 05/18/1983 is 30454 (...and also 00/01/1900 is 0!)).
To answer the initial question, I suggest this writing:
bearing in mind:
The MERGEFORMAT option is useful to keep the correct format.
Also, for those who are not used to working with Word fields:
That would do for 05/18/1983 (I changed 1st of January, which is 01/01 to 18th of avoid confusion):
我建议计算两个日期的序列号,然后将它们相减。它不必太复杂:无论如何我们只对年数感兴趣。 年*365 + 月*31 + 日 在这里应该很好。
对于年数,将差值除以 365。然后使用 INT 去掉小数部分(不是 ROUND,这会让你在半年中老一岁)。
I would suggest calculating a serial number for both dates and subtracting them from each other. It doesn't have to be too involved: we're only interested in the number of years anyway. year*365 + month*31 + day should do nicely here.
For the number of years divide the difference by 365. Then strip the fractional part using INT (not ROUND which would make you 1 year older half of the year).
{={DATE \@ "yyyy"} — {BirthDate \@ "yyyy"}}
{={DATE \@ "yyyy"} — {BirthDate \@ "yyyy"}}
我做了这样的事情:
我已将“10.2014”映射为名称为“d1”的书签(插入>书签)(稍后会派上用场。“05.2020”是“日期”(插入>字段> Date) 格式为
{DATE \@ "MM.yyyy"}
。 要访问此值,RMB > 切换字段代码下一步是计算“5 年零 8 个月”的差异。为此,我分别计算了“年”和“月”数字,有两个不同的字段,如下所示:
field1years,field2months其中
它可以进一步调整以显示“year”或“years”,“month”或“months”,但对我来说就足够了。
一些进一步的解释:
{}
。使用Ctrl+F9插入字段I've done something like this:
I've mapped "10.2014" as bookmark (insert > bookmark) with the name "d1" (it will come in handy later. "05.2020" is the "Date" (insert > field > Date) formatted as
{DATE \@ "MM.yyyy"}
. To access this, RMB > Toggle Field CodesThe next step is compute the "5 years, 8 months" difference. For this, I've computed separately the "years" and "months" numbers, with two different fields, as follows:
field1 years, field2 months where
It can be further tweaked to show "year" or "years", "month" or "months" , but for me was enough.
Some further explanations:
{}
. Use Ctrl+F9 to insert a field