SlideShare a Scribd company logo
1 of 12
Click to add Title
e-Infochips Institute of Training Research and Academics Limited
Date and Time Functions
Prepared by : Pranali Patel
Akshit Patel
Date and Time Functions
• The DATE data type is used to store date and time
information. The DATE data type has special
properties associated with it.
• It stores information about century, year, month,
day, hour, minute and second for each date value.
• The default format of Date data type is ‘DD-MM-
YY HH:MM:SS’.
• We can also change the date format using function.
Examples
• CURRENT_DATE:
It returns the current system date.
e.g.,
select current_date from dual;
11-APR-17
• CURRENT_TIMESTAMP:
It returns the current system date, time.
It is same as now() function.
e.g.,
select current_timestamp from dual;
11-APR-17 03.36.54.1000 PM
• ADD_MONTHS(d,n):
It returns the date adding number of month specified in the
function.
e.g.,
select add_months(sysdate, 3) from dual;
11-JULY-17
• LAST_DAY(d):
It returns the last date of the month specified with the
function.
e.g.,
select last_day(sysdate) from dual;
30-APR-17
Date conversion
• TO_CHAR:
It converts a value of DATE datatype to CHAR value.
e.g.,
select to_char ( sysdate, ‘month dd, yyyy’) from dual;
APRIL 11, 2017
• TO_DATE:
It converts characters field to date field.
e.g.,
select to_date (’11 april,2017’, ‘dd-mm-yyyy’) from dual;
11-APR-17
• NEXT_DAY(d,c):
It returns the date of the first week day named by c, that is
after the date named by d.
e.g.,
select next_day ( sysdate, ‘Monday’) from dual;
17-APR-2017
• MONTHS_BETWEEN(d1,d2):
It returns the number of months between d1 and d2.
e.g.,
select months_between( ‘11-july-17’, sysdate) from dual;
3
• ROUND:
It returns a date rounded to specific unit of measure.
e.g.,
select round(sysdate, ’yyyy’) from dual;
1-JAN-2017
• DATEDIFF(d1,d2):
It returns the difference between two dates.
e.g.,
SELECT datediff('2017-04-15',CURRENT_DATE)
from DUAL;
4
• DAYOFMONTH(d):
It returns a date of month.
e.g.,
SELECT dayofmonth(sysdate);
11
• DAYOFYEAR(d):
It returns a day of the year (in range 1 to 366).
e.g.,
SELECT dayofyear(sysdate);
101
• DAYOFWEEK(d):
It returns a weekday index for specified date.
e.g.,
SELECT dayofweek(sysdate);
3
• FROM_DAYS(n):
It returns the date value according to given number.
e.g.,
SELECT from_days(366) from dual;
0001-01-01
• MAKEDATE(y,n):
It returns a date according to given year and day of year
value.
e.g.,
select makedate (2017, 101) from dual;
2017-04-11
• QUARTER(d):
e.g.,
SELECT quarter(now()) from dual;
2
• SEC_TO_TIME(n):
e.g.,
SELECT sec_to_time(1234) from dual;
00:20:34
• Time(t):
e.g.,
SELECT time(now());
17:02:38
• TIME_TO_SEC(t):
e.g.,
SELECT time_to_sec(now()) from dual;
61541
• HOUR(t):
e.g.,
SELECT hour(now()) from dual;
17
• MINUTE(t):
e.g.,
SELECT minute(now()) from dual;
15
Thank you

More Related Content

What's hot

What's hot (20)

SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
Group By, Having Clause and Order By clause
Group By, Having Clause and Order By clause Group By, Having Clause and Order By clause
Group By, Having Clause and Order By clause
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operators
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NET
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
Pandas csv
Pandas csvPandas csv
Pandas csv
 
Dbms ii mca-ch5-ch6-relational algebra-2013
Dbms ii mca-ch5-ch6-relational algebra-2013Dbms ii mca-ch5-ch6-relational algebra-2013
Dbms ii mca-ch5-ch6-relational algebra-2013
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
 
Database Objects
Database ObjectsDatabase Objects
Database Objects
 
Structure in C
Structure in CStructure in C
Structure in C
 
File organization and introduction of DBMS
File organization and introduction of DBMSFile organization and introduction of DBMS
File organization and introduction of DBMS
 
database language ppt.pptx
database language ppt.pptxdatabase language ppt.pptx
database language ppt.pptx
 
Array in C
Array in CArray in C
Array in C
 
DBMS Notes: DDL DML DCL
DBMS Notes: DDL DML DCLDBMS Notes: DDL DML DCL
DBMS Notes: DDL DML DCL
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Including Constraints -Oracle Data base
Including Constraints -Oracle Data base Including Constraints -Oracle Data base
Including Constraints -Oracle Data base
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 

Similar to Date time function in Database

Date and Timestamp Types In Snowflake (By Faysal Shaarani)
Date and Timestamp Types In Snowflake (By Faysal Shaarani)Date and Timestamp Types In Snowflake (By Faysal Shaarani)
Date and Timestamp Types In Snowflake (By Faysal Shaarani)Faysal Shaarani (MBA)
 
Modify the Date class that was covered in the lecture which overload.pdf
Modify the Date class that was covered in the lecture which overload.pdfModify the Date class that was covered in the lecture which overload.pdf
Modify the Date class that was covered in the lecture which overload.pdfsaxenaavnish1
 
Hi,I have implemented increment() method. Please find the below up.pdf
Hi,I have implemented increment() method. Please find the below up.pdfHi,I have implemented increment() method. Please find the below up.pdf
Hi,I have implemented increment() method. Please find the below up.pdfAnkitchhabra28
 
Tactical data engineering
Tactical data engineeringTactical data engineering
Tactical data engineeringJulian Hyde
 
publicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdf
publicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdfpublicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdf
publicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdfmukhtaransarcloth
 
UNIT 3_Part I_GUIDELINES FOR CLASS DESIGN.pdf
UNIT 3_Part I_GUIDELINES FOR CLASS DESIGN.pdfUNIT 3_Part I_GUIDELINES FOR CLASS DESIGN.pdf
UNIT 3_Part I_GUIDELINES FOR CLASS DESIGN.pdfGauravDwivedi695361
 
Synapse india dotnet development overloading operater part 4
Synapse india dotnet development overloading operater part 4Synapse india dotnet development overloading operater part 4
Synapse india dotnet development overloading operater part 4Synapseindiappsdevelopment
 
Manipulating data with dates
Manipulating data with datesManipulating data with dates
Manipulating data with datesRupak Roy
 
Excel DATEDIFF Function
Excel DATEDIFF FunctionExcel DATEDIFF Function
Excel DATEDIFF FunctionExcel
 
How to work with dates and times in swift 3
How to work with dates and times in swift 3How to work with dates and times in swift 3
How to work with dates and times in swift 3allanh0526
 
Date data type and Globalization in Oracle
Date data type and Globalization in OracleDate data type and Globalization in Oracle
Date data type and Globalization in OracleMasoud Haji Hassan Pour
 
14. Alex Lightstone & Bill Prescot - Exploiting PeopleSoft Query & Pivot Grids
14. Alex Lightstone & Bill Prescot - Exploiting PeopleSoft Query & Pivot Grids14. Alex Lightstone & Bill Prescot - Exploiting PeopleSoft Query & Pivot Grids
14. Alex Lightstone & Bill Prescot - Exploiting PeopleSoft Query & Pivot GridsCedar Consulting
 
13 -times_and_dates
13  -times_and_dates13  -times_and_dates
13 -times_and_datesHector Garzo
 
Data Exploration with Apache Drill: Day 2
Data Exploration with Apache Drill: Day 2Data Exploration with Apache Drill: Day 2
Data Exploration with Apache Drill: Day 2Charles Givre
 
COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation Hemantha Kulathilake
 
Please I am posting the fifth time and hoping to get this r.pdf
Please I am posting the fifth time and hoping to get this r.pdfPlease I am posting the fifth time and hoping to get this r.pdf
Please I am posting the fifth time and hoping to get this r.pdfankit11134
 

Similar to Date time function in Database (20)

datetimefuction-170413055211.pptx
datetimefuction-170413055211.pptxdatetimefuction-170413055211.pptx
datetimefuction-170413055211.pptx
 
Date and Timestamp Types In Snowflake (By Faysal Shaarani)
Date and Timestamp Types In Snowflake (By Faysal Shaarani)Date and Timestamp Types In Snowflake (By Faysal Shaarani)
Date and Timestamp Types In Snowflake (By Faysal Shaarani)
 
Modify the Date class that was covered in the lecture which overload.pdf
Modify the Date class that was covered in the lecture which overload.pdfModify the Date class that was covered in the lecture which overload.pdf
Modify the Date class that was covered in the lecture which overload.pdf
 
Hi,I have implemented increment() method. Please find the below up.pdf
Hi,I have implemented increment() method. Please find the below up.pdfHi,I have implemented increment() method. Please find the below up.pdf
Hi,I have implemented increment() method. Please find the below up.pdf
 
Week2a.pptx
Week2a.pptxWeek2a.pptx
Week2a.pptx
 
Computer programming 2 Lesson 14
Computer programming 2  Lesson 14Computer programming 2  Lesson 14
Computer programming 2 Lesson 14
 
Tactical data engineering
Tactical data engineeringTactical data engineering
Tactical data engineering
 
publicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdf
publicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdfpublicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdf
publicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdf
 
UNIT 3_Part I_GUIDELINES FOR CLASS DESIGN.pdf
UNIT 3_Part I_GUIDELINES FOR CLASS DESIGN.pdfUNIT 3_Part I_GUIDELINES FOR CLASS DESIGN.pdf
UNIT 3_Part I_GUIDELINES FOR CLASS DESIGN.pdf
 
Synapse india dotnet development overloading operater part 4
Synapse india dotnet development overloading operater part 4Synapse india dotnet development overloading operater part 4
Synapse india dotnet development overloading operater part 4
 
Manipulating data with dates
Manipulating data with datesManipulating data with dates
Manipulating data with dates
 
Excel DATEDIFF Function
Excel DATEDIFF FunctionExcel DATEDIFF Function
Excel DATEDIFF Function
 
How to work with dates and times in swift 3
How to work with dates and times in swift 3How to work with dates and times in swift 3
How to work with dates and times in swift 3
 
Date data type and Globalization in Oracle
Date data type and Globalization in OracleDate data type and Globalization in Oracle
Date data type and Globalization in Oracle
 
14. Alex Lightstone & Bill Prescot - Exploiting PeopleSoft Query & Pivot Grids
14. Alex Lightstone & Bill Prescot - Exploiting PeopleSoft Query & Pivot Grids14. Alex Lightstone & Bill Prescot - Exploiting PeopleSoft Query & Pivot Grids
14. Alex Lightstone & Bill Prescot - Exploiting PeopleSoft Query & Pivot Grids
 
13 -times_and_dates
13  -times_and_dates13  -times_and_dates
13 -times_and_dates
 
Data Exploration with Apache Drill: Day 2
Data Exploration with Apache Drill: Day 2Data Exploration with Apache Drill: Day 2
Data Exploration with Apache Drill: Day 2
 
COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation
 
MySQL Functions
MySQL FunctionsMySQL Functions
MySQL Functions
 
Please I am posting the fifth time and hoping to get this r.pdf
Please I am posting the fifth time and hoping to get this r.pdfPlease I am posting the fifth time and hoping to get this r.pdf
Please I am posting the fifth time and hoping to get this r.pdf
 

Recently uploaded

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Recently uploaded (20)

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

Date time function in Database

  • 1. Click to add Title e-Infochips Institute of Training Research and Academics Limited Date and Time Functions Prepared by : Pranali Patel Akshit Patel
  • 2. Date and Time Functions • The DATE data type is used to store date and time information. The DATE data type has special properties associated with it. • It stores information about century, year, month, day, hour, minute and second for each date value. • The default format of Date data type is ‘DD-MM- YY HH:MM:SS’. • We can also change the date format using function.
  • 3. Examples • CURRENT_DATE: It returns the current system date. e.g., select current_date from dual; 11-APR-17 • CURRENT_TIMESTAMP: It returns the current system date, time. It is same as now() function. e.g., select current_timestamp from dual; 11-APR-17 03.36.54.1000 PM
  • 4. • ADD_MONTHS(d,n): It returns the date adding number of month specified in the function. e.g., select add_months(sysdate, 3) from dual; 11-JULY-17 • LAST_DAY(d): It returns the last date of the month specified with the function. e.g., select last_day(sysdate) from dual; 30-APR-17
  • 5. Date conversion • TO_CHAR: It converts a value of DATE datatype to CHAR value. e.g., select to_char ( sysdate, ‘month dd, yyyy’) from dual; APRIL 11, 2017 • TO_DATE: It converts characters field to date field. e.g., select to_date (’11 april,2017’, ‘dd-mm-yyyy’) from dual; 11-APR-17
  • 6. • NEXT_DAY(d,c): It returns the date of the first week day named by c, that is after the date named by d. e.g., select next_day ( sysdate, ‘Monday’) from dual; 17-APR-2017 • MONTHS_BETWEEN(d1,d2): It returns the number of months between d1 and d2. e.g., select months_between( ‘11-july-17’, sysdate) from dual; 3
  • 7. • ROUND: It returns a date rounded to specific unit of measure. e.g., select round(sysdate, ’yyyy’) from dual; 1-JAN-2017 • DATEDIFF(d1,d2): It returns the difference between two dates. e.g., SELECT datediff('2017-04-15',CURRENT_DATE) from DUAL; 4
  • 8. • DAYOFMONTH(d): It returns a date of month. e.g., SELECT dayofmonth(sysdate); 11 • DAYOFYEAR(d): It returns a day of the year (in range 1 to 366). e.g., SELECT dayofyear(sysdate); 101 • DAYOFWEEK(d): It returns a weekday index for specified date. e.g., SELECT dayofweek(sysdate); 3
  • 9. • FROM_DAYS(n): It returns the date value according to given number. e.g., SELECT from_days(366) from dual; 0001-01-01 • MAKEDATE(y,n): It returns a date according to given year and day of year value. e.g., select makedate (2017, 101) from dual; 2017-04-11
  • 10. • QUARTER(d): e.g., SELECT quarter(now()) from dual; 2 • SEC_TO_TIME(n): e.g., SELECT sec_to_time(1234) from dual; 00:20:34 • Time(t): e.g., SELECT time(now()); 17:02:38
  • 11. • TIME_TO_SEC(t): e.g., SELECT time_to_sec(now()) from dual; 61541 • HOUR(t): e.g., SELECT hour(now()) from dual; 17 • MINUTE(t): e.g., SELECT minute(now()) from dual; 15