/**
*
* @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技巧:取上周一到上周日(本周一到本周日\下周一到下周日)的时间...