'
//php获取今日开始时间戳和结束时间戳?
$beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'))
$endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1
echo?"今日开始时间戳和结束时间戳",'开始:',$beginToday,'结束:',$endToday,'
'
echo?"今日开始时间:",date("Y-m-d?H:i:s",$beginToday),'
'
echo?"今日结束时间:",date("Y-m-d?H:i:s",$endToday),'
'
echo?''
//php获取昨日起始时间戳和结束时间戳
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'))
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1?
echo?"昨日开始时间戳和结束时间戳",'开始:',$beginYesterday,'结束:',$endYesterday,'
'
echo?"昨日开始时间:",date("Y-m-d?H:i:s",$beginYesterday),'
'
echo?"昨日结束时间:",date("Y-m-d?H:i:s",$endYesterday),'
'
echo?''
//php获取上周起始时间戳和结束时间戳
$beginLastweek=mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y'))
$endLastweek=mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y'))
echo?"上周开始时间戳和结束时间戳",'开始:',$beginLastweek,'结束:',$endLastweek,'
'
echo?"上周开始时间:",date("Y-m-d?H:i:s",$beginLastweek),'
'
echo?"上周结束时间:",date("Y-m-d?H:i:s",$endLastweek),'
'
echo?''
//php获取本月起始时间戳和结束时间戳
$beginThismonth=mktime(0,0,0,date('m'),1,date('Y'))
$endThismonth=mktime(23,59,59,date('m'),date('t'),date('Y'))
echo?"本月开始时间戳和结束时间戳",'开始:',$beginThismonth,'结束:',$endThismonth,'
'
echo?"本月开始时间:",date("Y-m-d?H:i:s",$beginThismonth),'
'
echo?"本月结束时间:",date("Y-m-d?H:i:s",$endThismonth),'
'
?>
以A表为例子先建立一个table0
create table_0
(n_date date,
sheng varchar2(20),
sale number
tongbi number)
create unique index table_0_U1 on table_0 (n_date,sheng)
create or replace package body pkg_b_tongji is
procedure sp_update_party_rating(p_sdate number, p_edate number) is
v_sdate date default to_date(p_sdate,'yyyymmdd')
v_edate date default to_date(p_edate,'yyyymmdd')
v_sqlUpd varchar2(3000)
v_sqlIns varchar2(3000)
begin
v_sqlIns := 'insert into table_0(n_date,sheng,sale)
values(:v1,:v2,:v3)'
v_sqlUpd := 'update table_0 t set sale = :v1
where n_date = :v2 and sheng = :v3'
for c1 in (select a.ndate,
a.sheng,
sum(sale) sale
from a
where ndate between v_sdate and v_edate
group by a.ndate,
a.sheng
)
loop
execute immediate v_sqlUpd using c1.sale
if sql%rowcount<=0 then --如果更新 *** 作没有执行就执行插入 *** 作
execute immediate v_sqlIns using c1.n_date,c1.sheng,c1.sale
end if
end loop
commit
end sp_update_party_rating
---更新同比
procedure sp_update_tongbi is
begin
for c2 in (
select n_date,
sheng,
sale,
nvl(sale,0) sale1
from table_0 a
left join
(select n_date,sheng,a.nvl(sale,0) sale
from table_0 a,
(select t.n_date,sheng
add_months(n_date,-1) n_date2
from table_0 t)
where a.sheng = b.sheng and a.n_date = b.n_date2)
)
loop
update table_0
set tongbi = sale/sale1
where n_date = c2.n_date and sheng = c2.sheng
commit
end loop
end sp_update_tongbi
end pkg_b_tongji
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)