how to get begin of month and or end of month
select trunc(sysdate, 'MM') as start_date,
add_months(trunc(sysdate, 'MM'), 1) - 1 as end_date
from dual;
add_months(trunc(sysdate, 'MM'), 1) - 1 as end_date
from dual;
Script dibawah ini berfungsi untuk membandingkan antara tanggal sekarang dengan awal bulan. Dapat berfungsi juga sebagai validasi.
select case
when to_number(to_char(sysdate, 'dd')) =
to_number(to_char(trunc(sysdate, 'MM'), 'dd')) then
'Sama'
else
'Beda'
end,
to_number(to_char(sysdate, 'dd')),
to_number(to_char(trunc(sysdate, 'MM'), 'dd'))
from dual;
Semoga bermanfaat dan selamat mencoba, serta tidak lupa untuk comment - comment nya.
when to_number(to_char(sysdate, 'dd')) =
to_number(to_char(trunc(sysdate, 'MM'), 'dd')) then
'Sama'
else
'Beda'
end,
to_number(to_char(sysdate, 'dd')),
to_number(to_char(trunc(sysdate, 'MM'), 'dd'))
from dual;
0 comments:
Post a Comment