-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDATE_QUERIES.sql
More file actions
45 lines (37 loc) · 1.29 KB
/
DATE_QUERIES.sql
File metadata and controls
45 lines (37 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
select 1 + TRUNC (CURRENT_DATE)
- TRUNC (CURRENT_DATE, 'IW') From DUAl;
Select LAST_DAY( CURRENT_DATE ) From DUAl;
Select NEXT_DAY( CURRENT_DATE, 'SUNDAY' ) - 7 From DUAl;
select case to_char (sysdate, 'FmDay', 'nls_date_language=english')
when 'Monday' then 1
when 'Tuesday' then 2
when 'Wednesday' then 3
when 'Thursday' then 4
when 'Friday' then 5
when 'Saturday' then 6
when 'sunday' then 7
end d
from dual;
create or replace FUNCTION F_GET_DAY_LAST_OF_MONTH(
startdate IN VARCHAR2
)
RETURN DATE
RESULT_CACHE
RELIES_ON (S)
AS
Last_of_the_month NUMBER; -- 0 is true and 1 if false
nbreakpoint NUMBER;
BEGIN
nbreakpoint := 1;
Select LAST_DAY( startdate )
INTO Last_of_the_month
From DUAL;
DBMS_OUTPUT.PUT_LINE('F_IS_DAY_LAST_OF_MONTH succeded at checkpoint ' || nbreakpoint ||
' with result ' || Last_of_the_month || '.');
RETURN Last_of_the_month;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('F_IS_DAY_LAST_OF_MONTH failed at checkpoint ' || nbreakpoint ||
' with error ' || SQLCODE || ' : ' || SQLERRM);
RAISE;
END F_GET_DAY_LAST_OF_MONTH;