1. table 1: date1,date2
2. table 2: 记录休息日现在需要检索table1 中开发所用天数(date2-date1 出去休息日) ,如何写?例如:
table1: date2=2007-05-09 date1=2007-05-06
table2: 2007-05-06,2007-05-07
实际天数: 2 天 ,不是4天(因为5,6休息)谢谢指导!
2. table 2: 记录休息日现在需要检索table1 中开发所用天数(date2-date1 出去休息日) ,如何写?例如:
table1: date2=2007-05-09 date1=2007-05-06
table2: 2007-05-06,2007-05-07
实际天数: 2 天 ,不是4天(因为5,6休息)谢谢指导!
的
select date2-date1-(select count(*) from table2 where 记录休息日>date1 and 记录休息日<date2 ) from table1 t
前面写的是date型varchar型的话,转化下
to_date('2007/02/05','yyyy/mm/dd')