
首先打开excel表格。
1、电脑打开excel表格2019版本。
2、打开Excel表格2019版本后,输入第一个日期。
3、输入第一个日期后,选中单元格下拉增序,然后点击右下角自动填充选项。
4、点击自动填充选项后,就可以选择以月还是以年填充了。
5、选择以月填充后,数据就可以逐月增加设置了。
表格,又称为表,即是一种可视化交流模式,又是一种组织整理数据的手段。
1、可以把日期月底描述为月末或月底,也可以用数字表示,比如一月末就是1月31日、二月末就是2月28日或2月29日。
2、此外,有时也会用"theendofthemonth"来表示日期月底。
使用month函数进行处理。
Excel版本参考:2010
1、选中B1单元格;
2、输入公式:=Month(A1),回车;
3、双击B1单元格,双击填充柄填充到B10;
4、查看效果
import javatextSimpleDateFormat;
import javautilCalendar;
import javautilDate;
public class Main {
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
public static void main(String args[]) {
Date d = new Date();
// 月初
Systemoutprintln("月初" + sdfformat(getMonthStart(d)));
// 月末
Systemoutprintln("月末" + sdfformat(getMonthEnd(d)));
Date date = getMonthStart(d);
Date monthEnd = getMonthEnd(d);
while (!dateafter(monthEnd)) {
Systemoutprintln(sdfformat(date));
date = getNext(date);
}
}
private static Date getMonthStart(Date date) {
Calendar calendar = CalendargetInstance();
calendarsetTime(date);
int index = calendarget(CalendarDAY_OF_MONTH);
calendaradd(CalendarDATE, (1 - index));
return calendargetTime();
}
private static Date getMonthEnd(Date date) {
Calendar calendar = CalendargetInstance();
calendarsetTime(date);
calendaradd(CalendarMONTH, 1);
int index = calendarget(CalendarDAY_OF_MONTH);
calendaradd(CalendarDATE, (-index));
return calendargetTime();
}
private static Date getNext(Date date) {
Calendar calendar = CalendargetInstance();
calendarsetTime(date);
calendaradd(CalendarDATE, 1);
return calendargetTime();
}
}
这是一个月的 你改改就能写出上个月的了吧
/--------------------------------------------
FUNC: 日期计算处理函数 CalcDate
PARA:
type
1: 获取date1当月的第一天 赋值到date2 其他参数无效
2: 获取date1当月的最后一天 赋值到date2 其他参数无效
3: 获取date1的num天之后的日期 赋值到date2, 当num为负值时获取date1之前的日期
4: 获取date1的num月之后的日期 赋值到date2, 当num为负值时获取date1之前的日期
若大于月末则赋值月末
5: 获取date1到date2之间的天数 赋值到num, 当date1大于date2时, num为负值
6: 获取date1到date2之间的月数 赋值到num, 当date1大于date2时, num为负值
7: 获取date1的num月之后的月末日期 赋值到date2, 当num为负值时获取date1之前的月末日期
8: 获取date1的num月之后的日期 赋值到date2, 当num为负值时获取date1的num月前的日期;若date1为20120229 num为12则date2为20130228
date1: 格式YYYYMMDD, 输入参数
date2: 格式YYYYMMDD, 输入参数/输出参数
num: 数字, 输入参数/输出参数 可正可负
RETURN VALUE:
0: 计算成功
非0: 计算失败
NOTICE: date2作为出口参数时不能是无结束符的字符串的中间字段
因为赋值时将会在date2的后面增加字符串结束符
--------------------------------------------/
int CalcDate(int type, const char date1, char date2, int num)
{
int Mday[]={29,31,28,31,30,31,30,31,31,30,31,30,31};
int result;
int month;
int yy, mm, dd, yy1, mm1;
char year[4+1], mon[2+1], day[2+1];
EXEC SQL BEGIN DECLARE SECTION;
char datebeg[8+1];
char dateend[8+1];
int inputnum;
EXEC SQL END DECLARE SECTION;
result = checkDate(date1);
if ( result != 0 ) return result10+2;
if ( type == 1 )
{
sprintf(date2, "%66s01", date1);
return 0;
}
if ( type == 2 )
{
memset(mon, 0, sizeof(mm));
memcpy(mon, date1+4, 2);
mm = atol(mon);
sprintf(date2, "%66s%02d", date1, Mday[mm-LeapFebruary(date1)]);
return 0;
}
if ( type == 3 )
{
memset(datebeg, 0, sizeof(datebeg));
memset(dateend, 0, sizeof(dateend));
memcpy(datebeg, date1, 8);
inputnum = num;
EXEC SQL select to_char((to_date(:datebeg,'yyyymmdd') + :inputnum),'yyyymmdd') into :dateend from dual;
if ( sqlcasqlcode != 0 ) return sqlcasqlcode;
memcpy(date2, dateend, 8);
return 0;
}
if ( type == 4 || type == 7 )
{
memset(year, 0, sizeof(year));
memset(mon, 0, sizeof(mon));
memset(day, 0, sizeof(day));
memcpy(year, date1, 4);
memcpy(mon, date1+4, 2);
memcpy(day, date1+6, 2);
yy = atol(year);
mm = atol(mon);
dd = atol(day);
month = yy12 + mm - 1;
month += num;
yy = month/12;
mm = month%12 + 1;
sprintf(date2, "%04d%02d%02d", yy, mm, dd);
if ( type == 4 )
{
if ( dd > Mday[mm-LeapFebruary(date2)] )
dd = Mday[mm-LeapFebruary(date2)];
}
if ( type == 7 )
{
dd = Mday[mm-LeapFebruary(date2)];
}
sprintf(date2, "%04d%02d%02d", yy, mm, dd);
return 0;
}
if ( type == 5 )
{
result = checkDate(date2);
if ( result != 0 ) return result10+4;
memset(datebeg, 0, sizeof(datebeg));
memset(dateend, 0, sizeof(dateend));
memcpy(datebeg, date1, 8);
memcpy(dateend, date2, 8);
EXEC SQL select (to_date(:dateend,'yyyymmdd')-to_date(:datebeg,'yyyymmdd')) into :inputnum from dual;
if ( sqlcasqlcode != 0 ) return sqlcasqlcode;
num = inputnum;
return 0;
}
if ( type == 6 )
{
result = checkDate(date2);
if ( result != 0 ) return result10+7;
memset(year, 0, sizeof(year));
memset(mon, 0, sizeof(mon));
memcpy(year, date1, 4);
memcpy(mon, date1+4, 2);
yy = atol(year);
mm = atol(mon);
memset(year, 0, sizeof(year));
memset(mon, 0, sizeof(mon));
memcpy(year, date2, 4);
memcpy(mon, date2+4, 2);
yy1 = atol(year);
mm1 = atol(mon);
num = (yy1-yy)12 + (mm1-mm);
return 0;
}
if ( type == 8 )
{
memset(datebeg, 0, sizeof(datebeg));
memset(dateend, 0, sizeof(dateend));
memcpy(datebeg, date1, LEN_DATE);
inputnum = num;
EXEC SQL select to_char(add_months(to_date(:datebeg,'yyyymmdd'),:inputnum),'yyyymmdd') into :dateend from dual;
if ( sqlcasqlcode != 0 ) return sqlcasqlcode;
memcpy(date2, dateend, LEN_DATE);
return 0;
}
}
建议
使用EOMONTH函数(备注:end of month,返回某个月月末日期的函数),配合调整单元格数字的日期格式。
公式
=eomonth(A1,-1)
释义
括号里第1个值表示需要引用的日期所在的单元格,第2个值表示需要返回的第x个月的这个x的数字,如果需要返回前一个月的月末日期则输入-1;如果需要返回当前月的月末日期则输入0;如果需要反馈下一个月的月末日期则输入1,以此类推。
举例
A1单元格数值为日期2022/2/1
B1单元格输入公式=eomonth(A1,-1),返回结果为数值44592
设置单元格格式-数字-日期的格式为“2012/3/14”后确认,复原为“2022/1/31”。
您也可以设置设置单元格格式-数字-日期的格式为“2012年3月”来实现针对某年某月的日期显示
总结EOMONTH公式配合数字格式,可根据某个日期返回任意前后月的日期。
以上就是关于表格日期到第三个月末怎么设置全部的内容,包括:表格日期到第三个月末怎么设置、日期月底怎么描述出来、EXCEL中怎么提取月末数据样本等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)