-
2021-05-08 14:54:52
1.取周的开始时间和结束时间:
开始时间(以星期一为开始时间):
SQL> select trunc(sysdate,'D')+1 from dual;
结束时间(以星期日为结束时间):
SQL> select trunc(sysdate,'D')+7 from dual;
2.取月的开始时间和结束时间:
月初时间:
SQL> select trunc(sysdate,'MM') from dual;
月末时间:
SQL> select last_day(sysdate) from dual;
3.取季的开始时间和结束时间:
季初时间:
SQL> select trunc(sysdate,'Q') from dual;
季末时间:
SQL> select add_months(trunc(sysdate,'Q'),3)-1 from dual;
4.取年的开始时间和结束时间:
年初时间:
SQL> select trunc(sysdate,'yyyy') from dual;
年末时间:
SQL> select add_months(trunc(sysdate,'yyyy'),12)-1 from dual;
更多相关内容 -
Java用于取得当前日期相对应的月初,月末,季初,季末,年初,年末时间
2021-03-07 22:39:14/**** 描述:此类用于取得当前日期相对应的月初,月末,季初,季末,年初,年末,返回值均为String字符串* 1、得到当前日期 today()* 2、得到当前月份月初 thisMonth()* 3、得到当前月份月底 thisMonth...package com.zrar.date;
import java.util.Calendar;
/**
*
* 描述:此类用于取得当前日期相对应的月初,月末,季初,季末,年初,年末,返回值均为String字符串
* 1、得到当前日期 today()
* 2、得到当前月份月初 thisMonth()
* 3、得到当前月份月底 thisMonthEnd()
* 4、得到当前季度季初 thisSeason()
* 5、得到当前季度季末 thisSeasonEnd()
* 6、得到当前年份年初 thisYear()
* 7、得到当前年份年底 thisYearEnd()
* 8、判断输入年份是否为闰年 leapYear
*
* 注意事项: 日期格式为:xxxx-yy-zz (eg: 2007-12-05)
*
* 实例:
*
* @author pure
*/
public class DateThis {
private int x; // 日期属性:年
private int y; // 日期属性:月
private int z; // 日期属性:日
private Calendar localTime; // 当前日期
public DateThis() {
localTime = Calendar.getInstance();
}
/**
* 功能:得到当前日期 格式为:xxxx-yy-zz (eg: 2007-12-05)
* @return String
* @author pure
*/
public String today() {
String strY = null;
String strZ = null;
x = localTime.get(Calendar.YEAR);
y = localTime.get(Calendar.MONTH) + 1;
z = localTime.get(Calendar.DATE);
strY = y >= 10 ? String.valueOf(y) : ("0" + y);
strZ = z >= 10 ? String.valueOf(z) : ("0" + z);
return x + "-" + strY + "-" + strZ;
}
/**
* 功能:得到当前月份月初 格式为:xxxx-yy-zz (eg: 2007-12-01)
* @return String
* @author pure
*/
public String thisMonth() {
String strY = null;
x = localTime.get(Calendar.YEAR);
y = localTime.get(Calendar.MONTH) + 1;
strY = y >= 10 ? String.valueOf(y) : ("0" + y);
return x + "-" + strY + "-01";
}
/**
* 功能:得到当前月份月底 格式为:xxxx-yy-zz (eg: 2007-12-31)
* @return String
* @author pure
*/
public String thisMonthEnd() {
String strY = null;
String strZ = null;
boolean leap = false;
x = localTime.get(Calendar.YEAR);
y = localTime.get(Calendar.MONTH) + 1;
if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
strZ = "31";
}
if (y == 4 || y == 6 || y == 9 || y == 11) {
strZ = "30";
}
if (y == 2) {
leap = leapYear(x);
if (leap) {
strZ = "29";
}
else {
strZ = "28";
}
}
strY = y >= 10 ? String.valueOf(y) : ("0" + y);
return x + "-" + strY + "-" + strZ;
}
/**
* 功能:得到当前季度季初 格式为:xxxx-yy-zz (eg: 2007-10-01)
* @return String
* @author pure
*/
public String thisSeason() {
String dateString = "";
x = localTime.get(Calendar.YEAR);
y = localTime.get(Calendar.MONTH) + 1;
if (y >= 1 && y <= 3) {
dateString = x + "-" + "01" + "-" + "01";
}
if (y >= 4 && y <= 6) {
dateString = x + "-" + "04" + "-" + "01";
}
if (y >= 7 && y <= 9) {
dateString = x + "-" + "07" + "-" + "01";
}
if (y >= 10 && y <= 12) {
dateString = x + "-" + "10" + "-" + "01";
}
return dateString;
}
/**
* 功能:得到当前季度季末 格式为:xxxx-yy-zz (eg: 2007-12-31)
* @return String
* @author pure
*/
public String thisSeasonEnd() {
String dateString = "";
x = localTime.get(Calendar.YEAR);
y = localTime.get(Calendar.MONTH) + 1;
if (y >= 1 && y <= 3) {
dateString = x + "-" + "03" + "-" + "31";
}
if (y >= 4 && y <= 6) {
dateString = x + "-" + "06" + "-" + "30";
}
if (y >= 7 && y <= 9) {
dateString = x + "-" + "09" + "-" + "30";
}
if (y >= 10 && y <= 12) {
dateString = x + "-" + "12" + "-" + "31";
}
return dateString;
}
/**
* 功能:得到当前年份年初 格式为:xxxx-yy-zz (eg: 2007-01-01)
* @return String
* @author pure
*/
public String thisYear() {
x = localTime.get(Calendar.YEAR);
return x + "-01" + "-01";
}
/**
* 功能:得到当前年份年底 格式为:xxxx-yy-zz (eg: 2007-12-31)
* @return String
* @author pure
*/
public String thisYearEnd() {
x = localTime.get(Calendar.YEAR);
return x + "-12" + "-31";
}
/**
* 功能:判断输入年份是否为闰年
*
* @param year
* @return 是:true 否:false
* @author pure
*/
public boolean leapYear(int year) {
boolean leap;
if (year % 4 == 0) {
if (year % 100 == 0) {
if (year % 400 == 0) leap = true;
else leap = false;
}
else leap = true;
}
else leap = false;
return leap;
}
}
-
Oracle中取月初,月末,季初,季末及年初,年末时间总结
2018-08-02 14:50:21在工作中通常会用到月初,月末,季初,季末,年初及年末的时间,在这里做一个简单的总结: 1.取周的开始时间和结束时间: 开始时间(以星期一为开始时间): SQL> select trunc(sysdate,'D')+1 ...在工作中通常会用到月初,月末,季初,季末,年初及年末的时间,在这里做一个简单的总结:
1.取周的开始时间和结束时间:
开始时间(以星期一为开始时间):
SQL> select trunc(sysdate,'D')+1 from dual;
结束时间(以星期日为结束时间):
SQL> select trunc(sysdate,'D')+7 from dual;
2.取月的开始时间和结束时间:
月初时间:
SQL> select trunc(sysdate,'MM') from dual;
月末时间:
SQL> select last_day(sysdate) from dual;
3.取季的开始时间和结束时间:
季初时间:
SQL> select trunc(sysdate,'Q') from dual;
季末时间:
SQL> select add_months(trunc(sysdate,'Q'),3)-1 from dual;
4.取年的开始时间和结束时间:
年初时间:
SQL> select trunc(sysdate,'yyyy') from dual;
年末时间:
SQL> select add_months(trunc(sysdate,'yyyy'),12)-1 from dual;
以上是在工作中常用的时间点,个人做个总结,大家相互学习!
-
用于取得当前日期相对应的月初,月末,季初,季末,年初,年末时间
2021-01-20 00:10:26/****描述:此类用于取得当前日期相对应的月初,月末,季初,季末,年初,年末,返回值均为String字符串*1、得到当前日期today()*2、得到当前月份月初thisMonth()*3、得到当前月份月底thisMonth...package com.zrar.date;
import java.util.Calendar;
/**
*
* 描述:此类用于取得当前日期相对应的月初,月末,季初,季末,年初,年末,返回值均为String字符串
* 1、得到当前日期 today()
* 2、得到当前月份月初 thisMonth()
* 3、得到当前月份月底 thisMonthEnd()
* 4、得到当前季度季初 thisSeason()
* 5、得到当前季度季末 thisSeasonEnd()
* 6、得到当前年份年初 thisYear()
* 7、得到当前年份年底 thisYearEnd()
* 8、判断输入年份是否为闰年 leapYear
*
* 注意事项: 日期格式为:xxxx-yy-zz (eg: 2007-12-05)
*
* 实例:
*
* @author pure
*/
public class DateThis {
private int x; // 日期属性:年
private int y; // 日期属性:月
private int z; // 日期属性:日
private Calendar localTime; // 当前日期
public DateThis() {
localTime = Calendar.getInstance();
}
/**
* 功能:得到当前日期 格式为:xxxx-yy-zz (eg: 2007-12-05)
* @return String
* @author pure
*/
public String today() {
String strY = null;
String strZ = null;
x = localTime.get(Calendar.YEAR);
y = localTime.get(Calendar.MONTH) + 1;
z = localTime.get(Calendar.DATE);
strY = y >= 10 ? String.valueOf(y) : ("0" + y);
strZ = z >= 10 ? String.valueOf(z) : ("0" + z);
return x + "-" + strY + "-" + strZ;
}
/**
* 功能:得到当前月份月初 格式为:xxxx-yy-zz (eg: 2007-12-01)
* @return String
* @author pure
*/
public String thisMonth() {
String strY = null;
x = localTime.get(Calendar.YEAR);
y = localTime.get(Calendar.MONTH) + 1;
strY = y >= 10 ? String.valueOf(y) : ("0" + y);
return x + "-" + strY + "-01";
}
/**
* 功能:得到当前月份月底 格式为:xxxx-yy-zz (eg: 2007-12-31)
* @return String
* @author pure
*/
public String thisMonthEnd() {
String strY = null;
String strZ = null;
boolean leap = false;
x = localTime.get(Calendar.YEAR);
y = localTime.get(Calendar.MONTH) + 1;
if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
strZ = "31";
}
if (y == 4 || y == 6 || y == 9 || y == 11) {
strZ = "30";
}
if (y == 2) {
leap = leapYear(x);
if (leap) {
strZ = "29";
}
else {
strZ = "28";
}
}
strY = y >= 10 ? String.valueOf(y) : ("0" + y);
return x + "-" + strY + "-" + strZ;
}
/**
* 功能:得到当前季度季初 格式为:xxxx-yy-zz (eg: 2007-10-01)
* @return String
* @author pure
*/
public String thisSeason() {
String dateString = "";
x = localTime.get(Calendar.YEAR);
y = localTime.get(Calendar.MONTH) + 1;
if (y >= 1 && y <= 3) {
dateString = x + "-" + "01" + "-" + "01";
}
if (y >= 4 && y <= 6) {
dateString = x + "-" + "04" + "-" + "01";
}
if (y >= 7 && y <= 9) {
dateString = x + "-" + "07" + "-" + "01";
}
if (y >= 10 && y <= 12) {
dateString = x + "-" + "10" + "-" + "01";
}
return dateString;
}
/**
* 功能:得到当前季度季末 格式为:xxxx-yy-zz (eg: 2007-12-31)
* @return String
* @author pure
*/
public String thisSeasonEnd() {
String dateString = "";
x = localTime.get(Calendar.YEAR);
y = localTime.get(Calendar.MONTH) + 1;
if (y >= 1 && y <= 3) {
dateString = x + "-" + "03" + "-" + "31";
}
if (y >= 4 && y <= 6) {
dateString = x + "-" + "06" + "-" + "30";
}
if (y >= 7 && y <= 9) {
dateString = x + "-" + "09" + "-" + "30";
}
if (y >= 10 && y <= 12) {
dateString = x + "-" + "12" + "-" + "31";
}
return dateString;
}
/**
* 功能:得到当前年份年初 格式为:xxxx-yy-zz (eg: 2007-01-01)
* @return String
* @author pure
*/
public String thisYear() {
x = localTime.get(Calendar.YEAR);
return x + "-01" + "-01";
}
/**
* 功能:得到当前年份年底 格式为:xxxx-yy-zz (eg: 2007-12-31)
* @return String
* @author pure
*/
public String thisYearEnd() {
x = localTime.get(Calendar.YEAR);
return x + "-12" + "-31";
}
/**
* 功能:判断输入年份是否为闰年
*
* @param year
* @return 是:true 否:false
* @author pure
*/
public boolean leapYear(int year) {
boolean leap;
if (year % 4 == 0) {
if (year % 100 == 0) {
if (year % 400 == 0) leap = true;
else leap = false;
}
else leap = true;
}
else leap = false;
return leap;
}
}
-
Java用于取得当前日期相对应的月初,月末,季初,季末,年初,年末时间详解
2020-12-24 07:35:52/**** 描述:此类用于取得当前日期相对应的月初,月末,季初,季末,年初,年末,返回值均为String字符串* 1、得到当前日期 today()* 2、得到当前月份月初 thisMonth()* 3、得到当前月份月底 thisMonth... -
查询年初,年末,去年年初,明年年初与年末sql语句
2021-01-19 02:30:23查询年初,年末,去年年初,明年年初与年末sql语句查询年初,年末,去年年初,明年年初与年末sql语句--年度计算declare @date datetimeset @date=getdate()--年初,计算给定日期所在年的第一天select dateadd(year,... -
Java根据当前日期获取年初,年末,季初,季末,月初,月末日期的方法
2020-07-20 11:45:00} 年末 public static Date getYearLast(){ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar ca = Calendar.getInstance(); ca.clear(Calendar.MONTH); ca.set... -
mysql获得当前时间,上个月的时间,去年的时间
2019-12-05 17:51:41当前时间:select now() 结果:2019-08-31 11:10:40 当前日期:select date(now()) 结果:2019-08-31 当前年月:select left(now(),7) 结果:2019-08 当前月份:select month(now()) 结果:8 当前年份:select year... -
oracle中取月初,月末,季初,季末及年初,年末时间
2021-05-10 11:23:211.取周的开始时间和结束时间: 开始时间(以星期一为开始时间): SQL> select trunc(sysdate,'D')+1 from dual; 结束时间(以星期日为结束时间): SQL> select trunc(sysdate,'D')+7 from dual; 2.... -
2013个人年末工作总结
2020-12-08 02:35:292013个人年末工作总结模板下载,每个时间段我们都需要对工作进行总结,在这里小编为大家提供2013个人年末...该文档为2013个人年末工作总结,是一份很不错的参考资料,具有较高参考价值,感兴趣的可以下载看看 -
房地产买卖个人年末总结
2020-12-07 20:32:42房地产买卖个人年末总结模板下载,每个时间段我们都需要对工作进行总结,在这里小编为大家提供房地产买卖...该文档为房地产买卖个人年末总结,是一份很不错的参考资料,具有较高参考价值,感兴趣的可以下载看看 -
Vue获取当前时间( 年初-年末、月初-月末、)
2021-10-14 10:46:06// 获取年初-年末、月初-月末、 getNowTime() { var now = new Date(); var year = now.getFullYear(); //得到年份 var month = now.getMonth(); //得到月份 var day = now.getDate(); //得到天 if (day < ... -
全国及31个省级失业保险 年末参加失业保险人数 年末领取失业保险金人数 失业保险基金收入 支出 结余2000-...
2022-04-12 09:58:30时间:2000-2020年 来源:文件内有每组数据来源的详细说明 格式:EXCEL表格 变量包括: 年末参加失业保险人数(万人)2000-2020年:无缺失值 年末领取失业保险金人数(万人)2000-2020年:缺失西藏2000、2003... -
db2中的时间函数(计算上年末,上月末,上季末)
2020-11-24 21:01:44#上年末 以日期2020-11-24为例 date(left(‘2020-11-24’,5)||‘01-01’) - 1 day #上月末 date(left(‘2020-11-24’,8)||‘01’) - 1 day #上季末 date(left(‘2020-11-24’,8)||‘01’) - 1 day - (mod(month(... -
RevISEE:计算您的Revolut帐户的平均每日余额和年末余额
2021-02-15 01:40:39计算您的Revolut帐户的平均每日余额和年末余额。 该实现遵循描述的算法。 外币账户的平均每日余额每天使用每日外汇价值转换为欧元。 由于检索历史性外汇价值的API速度很慢,因此请等待算法执行时间。 激活详细模式... -
04-oracle时间函数
2021-05-03 03:27:15--sqlplus下默认只显示年月日不显示时间,设置以24小时制和12小时制的语句分别如下:SQL> alter session set nls_date_format='yyyy-mm-dd hh12:mi:ss';Session altered.SQL> select sysdate from dual;... -
python获取年末,月末,季末的日期和距指定时间的天数
2020-05-22 15:29:37我们在python日常使用中经常会用到时间的各种计算,这个也是让人头疼的地方,下面的方法实现了 年末,月末,季末的日期和距指定时间的天数的计算,要的拿去。自己也做个笔记。后面直接用。 def last_day(any_day): ... -
oracle获取上一旬的开始时间和结束时间的实现函数
2021-05-02 04:21:09-- 获取上旬开始时间create or replace function fd_lastxunstart(rq in date) return string isrefstr varchar2(50);v_rq date;begin--获取上一旬的日期v_rq := trunc(rq);select case decode(trunc((to_char(v_rq,... -
python时间计算:当天、前一天、月初、月末、季初、季末、半年初、半年末、年初、年末
2020-12-24 00:29:12{'datadate': newdate} 年初: newdate = date.replace(month=1, day=1) condtions = {'datadate': newdate} 年末: newdate = date.replace(month=12, day=31) condtions = {'datadate': newdate} 去年初: newdate... -
用于取得当前日期相对应的月初,月末,季初,季末,年初,年末时间
2008-08-28 15:23:00用于取得当前日期相对应的月初,月末,季初,季末,年初,年末时间 今天自己写的一个用于取得当前日期相对应的月初,月末,季初,季末,年初,年末,返回值均为String字符串,方法比较土,使用字符串套接方法完成。...