可以用pg自带函数select extract(dow from current_date),之所以没用主要是展示一下通过数学方法计算日期的原理. drop function if exists getDateWeek(date);drop function if exists intervalDay(date);drop function if exists getMonMaxDay(integer,integer);drop function if exists getMonMaxDate(
-- 计算指定日期本周的第一天和最后一天 select day ,dayofweek(day) as dw1 ,date_add( - dayofweek(day)) as Su_s -- 周日_start ,date_add( - dayofweek(day)) as Sa_e -- 周六_end , end as dw2 ,date_add( end) as Mo_s -- 周一_start ,date_add( end) as Su_e -- 周日_end from ( select '2
在oracle里,如何取得本周.本月.本季度.本年度的第一天和最后一天的时间 --本周 select trunc(sysdate,'d')+1 from dual; select trunc(sysdate,'d')+7 from dual; --本月 select trunc(sysdate,'mm') from dual; select last_day(trunc(sysdate)) from dual; --本季 select trunc(sysdate,'Q') from dual;
/*取本周第一天(星期一),取本周最后一天(星期天)*/ SELECT trunc( SYSDATE, AS 星期一 , trunc( SYSDATE, AS 星期天 FROM dual; 效果如下: 不忘初心,如果您认为这篇文章有价值,认同作者的付出,可以微信二维码打赏任意金额给作者(微信号:382477247)哦,谢谢.
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace WyfClass { public class tools { /// <summary> /// 得到本周第一天(以星期天为第一天) /// </summary> /// <param name="datetime"></param> /// &l