Pages

SQL Time calculation queries

To display Current date:

SELECT SYSDATE FROM DUAL;

To display Yesterday's date and Tomorrow's date (Adding or subtracting days):

SELECT SYSDATE-1 YESTERDAY,SYSDATE+1 TOMORROW FROM DUAL;

To display first day of month :

SELECT TRUNC(SYSDATE,'MONTH')FirstDayMonth FROM DUAL;

To display first day of year:

SELECT TRUNC(SYSDATE,'YEAR')FirstDayYear FROM DUAL;

To display first day of week:

SELECT TRUNC(SYSDATE,'iw')FirstDayWeek FROM DUAL;

To display today's day name:

SELECT TO_CHAR(SYSDATE,'DAY')TODAY FROM DUAL;

To display current month name:

SELECT TO_CHAR(SYSDATE,'MONTH')MONTH FROM DUAL;

SELECT TO_CHAR(SYSDATE,'MON')MON FROM DUAL;





No comments:

Post a Comment

Featured post

Snowflake - Creating warehouse in Snowflake

Creating warehouse Login to Snowflake and click on warehouse and click on Create fill the necessary details and click Finish We can also c...