1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > oracle判断为周一_oracle sql技巧:取上周一到上周日(本周一到本周日\下周一到下周日

oracle判断为周一_oracle sql技巧:取上周一到上周日(本周一到本周日\下周一到下周日

时间:2021-02-21 04:41:01

相关推荐

oracle判断为周一_oracle sql技巧:取上周一到上周日(本周一到本周日\下周一到下周日

/**

*

* @param anObject: thisWeek=本周;nextWeek=下周

* @return monday

*/

public String getMonday(String anObject){

String sql="";

String time="";

if("thisWeek".equals(anObject))

sql="Select case when to_char(sysdate,'D')=1 then to_char(sysdate-to_char(sysdate,'D')-5,'yyyy-mm-dd') else to_char(sysdate-to_char(sysdate,'D')+2,'yyyy-mm-dd') end from dual";

else if("nextWeek".equals(anObject))

sql=" Select case when to_char(sysdate,'D')=1 then to_char(sysdate-to_char(sysdate,'D')+2,'yyyy-mm-dd') else to_char(sysdate-to_char(sysdate,'D')+9,'yyyy-mm-dd') end from dual";

else if("lastWeek".equals(anObject))//上周

sql="Select case when to_char(sysdate,'D')=1 then to_char(sysdate - to_char(sysdate, 'D') -12,'yyyy-mm-dd') else to_char(sysdate - to_char(sysdate, 'D') -5,'yyyy-mm-dd') end from dual";

time=this.getToCharSysdateParameter(sql);

return time;

}

/**

*

* @param anObject:thisWeek=本周;nextWeek=下周;lastWeek=上周

* @return sunday

*/

public String getSunday(String anObject){

String sql="";

String time="";

if("thisWeek".equals(anObject))//本周

sql="Select to_char(sysdate,'D'),case when to_char(sysdate,'D')=1 then to_char(sysdate-to_char(sysdate,'D')+1,'yyyy-mm-dd') else to_char(sysdate-to_char(sysdate,'D')+8,'yyyy-mm-dd') end from dual";

else if("nextWeek".equals(anObject))//下周

sql="Select to_char(sysdate,'D'),case when to_char(sysdate,'D')=1 then to_char(sysdate-to_char(sysdate,'D')+8,'yyyy-mm-dd') else to_char(sysdate-to_char(sysdate,'D')+15,'yyyy-mm-dd') end from dual";

else if("lastWeek".equals(anObject))//上周

sql="Select case when to_char(sysdate,'D')=1 then to_char(sysdate - to_char(sysdate, 'D') -6,'yyyy-mm-dd') else to_char(sysdate - to_char(sysdate, 'D') +1,'yyyy-mm-dd') end from dual";

time=this.getToCharSysdateParameter(sql);

return time;

}

oracle判断为周一_oracle sql技巧:取上周一到上周日(本周一到本周日\下周一到下周日)的时间...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。