简体   繁体   English

如何从Excel中的TODAY函数获得一年中的第一个月?

[英]How to get first month of the year from TODAY Function in Excel?

In a excel sheet range A1:A12 , I need months like:在 Excel 工作表范围A1:A12 中,我需要几个月的时间:

Jan 2020 to Dec 2020 for current year. 2020 年 1 月202012 月为本年度。

and Jan 2021 to Dec 2021 for next year.以及明年的2021 年1 月202112 月 and so on.等等。 Automatically.自动地。

I google it but did not find any suitable result.我用谷歌搜索但没有找到任何合适的结果。

Plz help me and ignore my weak English and grammar.请帮助我并忽略我的英语和语法薄弱。

Thank You.谢谢你。

Use below formula-使用以下公式-

=TEXT(DATE(2020+INT(ROW()/13),MOD(ROW(),13)+INT(ROW()/13),1),"mmm-yyyy")

在此处输入图片说明

Let's say you want a real date, using the 1st of each month (you can then format the cells to just show mmm yyyy or whatever other format you like).假设您想要一个真实的日期,使用每个月的 1 号(然后您可以格式化单元格以仅显示mmm yyyy或您喜欢的任何其他格式)。 In your first cell enter:在您的第一个单元格中输入:

=DATE(YEAR(TODAY()),ROWS($A$1:$A1),1)

and copy it down.并将其复制下来。 If you actually want the month as text, just wrap that in the TEXT function:如果您确实希望将月份作为文本,只需将其包装在 TEXT 函数中:

=TEXT(DATE(YEAR(TODAY()),ROWS($A$1:$A1),1),"mmm yyyy")

Note that the DATE function will happily adjust the year if you pass a month number greater than 12.请注意,如果您传递的月份数字大于 12,则DATE函数将很乐意调整年份。

To get This using =TODAY() function you have to use 2 cells.要使用=TODAY()函数获得 This,您必须使用 2 个单元格。

Let's use A1 and B1 as the 2 cells.让我们使用 A1 和 B1 作为 2 个单元格。 In A1 you will display today's dat as dd/mm/yyyy在 A1 中,您将今天的数据显示为 dd/mm/yyyy

=TODAY() type this in A1 =TODAY()在 A1 中输入

In B1 you will convert it to month and year.在 B1 中,您将其转换为月份和年份。

=TEXT(A1,"mmm-yyyy") type this in B1 =TEXT(A1,"mmm-yyyy")在 B1 中输入

But using this method you can only get this month.但使用这种方法,你只能得到这个月。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM