SlideShare a Scribd company logo
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

Similar to datetimefuction-170413055211.pptx

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
 
Tactical data engineering
Tactical data engineeringTactical data engineering
Tactical data engineeringJulian Hyde
 
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
 
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
 
Manipulating data with dates
Manipulating data with datesManipulating data with dates
Manipulating data with datesRupak Roy
 
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
 
13 -times_and_dates
13  -times_and_dates13  -times_and_dates
13 -times_and_datesHector Garzo
 
C++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfC++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfjaipur2
 
Excel DATEDIFF Function
Excel DATEDIFF FunctionExcel DATEDIFF Function
Excel DATEDIFF FunctionExcel
 
How to write SQL queries | pgDay Paris 2019 | Dimitri Fontaine
How to write SQL queries | pgDay Paris 2019 | Dimitri FontaineHow to write SQL queries | pgDay Paris 2019 | Dimitri Fontaine
How to write SQL queries | pgDay Paris 2019 | Dimitri FontaineCitus Data
 
Data Wrangling: Working with Date / Time Data and Visualizing It
Data Wrangling: Working with Date / Time Data and Visualizing ItData Wrangling: Working with Date / Time Data and Visualizing It
Data Wrangling: Working with Date / Time Data and Visualizing Itkanaugust
 
SessionSeven_WorkingWithDatesandTime
SessionSeven_WorkingWithDatesandTimeSessionSeven_WorkingWithDatesandTime
SessionSeven_WorkingWithDatesandTimeHellen Gakuruh
 
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
 
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
 
Date class that represents a date consisting of a year, month, and a.pdf
Date class that represents a date consisting of a year, month, and a.pdfDate class that represents a date consisting of a year, month, and a.pdf
Date class that represents a date consisting of a year, month, and a.pdfanilgoelslg
 
Python and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri Fontaine
Python and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri FontainePython and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri Fontaine
Python and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri FontaineCitus Data
 
Useful date number and string sql queries
Useful date number and string sql queriesUseful date number and string sql queries
Useful date number and string sql queriesFeras Ahmad
 
Sofware engineering
Sofware engineeringSofware engineering
Sofware engineeringKavi Kumar
 

Similar to datetimefuction-170413055211.pptx (20)

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
 
Tactical data engineering
Tactical data engineeringTactical data engineering
Tactical data engineering
 
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
 
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
 
Manipulating data with dates
Manipulating data with datesManipulating data with dates
Manipulating data with dates
 
COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation
 
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
 
13 -times_and_dates
13  -times_and_dates13  -times_and_dates
13 -times_and_dates
 
C++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfC++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdf
 
Excel DATEDIFF Function
Excel DATEDIFF FunctionExcel DATEDIFF Function
Excel DATEDIFF Function
 
MySQL Functions
MySQL FunctionsMySQL Functions
MySQL Functions
 
How to write SQL queries | pgDay Paris 2019 | Dimitri Fontaine
How to write SQL queries | pgDay Paris 2019 | Dimitri FontaineHow to write SQL queries | pgDay Paris 2019 | Dimitri Fontaine
How to write SQL queries | pgDay Paris 2019 | Dimitri Fontaine
 
Data Wrangling: Working with Date / Time Data and Visualizing It
Data Wrangling: Working with Date / Time Data and Visualizing ItData Wrangling: Working with Date / Time Data and Visualizing It
Data Wrangling: Working with Date / Time Data and Visualizing It
 
SessionSeven_WorkingWithDatesandTime
SessionSeven_WorkingWithDatesandTimeSessionSeven_WorkingWithDatesandTime
SessionSeven_WorkingWithDatesandTime
 
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
 
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
 
Date class that represents a date consisting of a year, month, and a.pdf
Date class that represents a date consisting of a year, month, and a.pdfDate class that represents a date consisting of a year, month, and a.pdf
Date class that represents a date consisting of a year, month, and a.pdf
 
Python and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri Fontaine
Python and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri FontainePython and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri Fontaine
Python and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri Fontaine
 
Useful date number and string sql queries
Useful date number and string sql queriesUseful date number and string sql queries
Useful date number and string sql queries
 
Sofware engineering
Sofware engineeringSofware engineering
Sofware engineering
 

More from YashaswiniSrinivasan1 (9)

1-161103092724.pptx
1-161103092724.pptx1-161103092724.pptx
1-161103092724.pptx
 
introductionofssis-130418034853-phpapp01.pptx
introductionofssis-130418034853-phpapp01.pptxintroductionofssis-130418034853-phpapp01.pptx
introductionofssis-130418034853-phpapp01.pptx
 
thegrowingimportanceofdatacleaning-211202141902.pptx
thegrowingimportanceofdatacleaning-211202141902.pptxthegrowingimportanceofdatacleaning-211202141902.pptx
thegrowingimportanceofdatacleaning-211202141902.pptx
 
stored.ppt
stored.pptstored.ppt
stored.ppt
 
Chapter5.ppt
Chapter5.pptChapter5.ppt
Chapter5.ppt
 
database.ppt
database.pptdatabase.ppt
database.ppt
 
ms-sql-server-150223140402-conversion-gate02.pptx
ms-sql-server-150223140402-conversion-gate02.pptxms-sql-server-150223140402-conversion-gate02.pptx
ms-sql-server-150223140402-conversion-gate02.pptx
 
lecture-sql.ppt
lecture-sql.pptlecture-sql.ppt
lecture-sql.ppt
 
ch1.ppt
ch1.pptch1.ppt
ch1.ppt
 

Recently uploaded

FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance
 
КАТЕРИНА АБЗЯТОВА «Ефективне планування тестування ключові аспекти та практ...
КАТЕРИНА АБЗЯТОВА  «Ефективне планування тестування  ключові аспекти та практ...КАТЕРИНА АБЗЯТОВА  «Ефективне планування тестування  ключові аспекти та практ...
КАТЕРИНА АБЗЯТОВА «Ефективне планування тестування ключові аспекти та практ...QADay
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesThousandEyes
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance
 
UiPath New York Community Day in-person event
UiPath New York Community Day in-person eventUiPath New York Community Day in-person event
UiPath New York Community Day in-person eventDianaGray10
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...Product School
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Thierry Lestable
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...Product School
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxAbida Shariff
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...Sri Ambati
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsVlad Stirbu
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
КАТЕРИНА АБЗЯТОВА «Ефективне планування тестування ключові аспекти та практ...
КАТЕРИНА АБЗЯТОВА  «Ефективне планування тестування  ключові аспекти та практ...КАТЕРИНА АБЗЯТОВА  «Ефективне планування тестування  ключові аспекти та практ...
КАТЕРИНА АБЗЯТОВА «Ефективне планування тестування ключові аспекти та практ...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
UiPath New York Community Day in-person event
UiPath New York Community Day in-person eventUiPath New York Community Day in-person event
UiPath New York Community Day in-person event
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 

datetimefuction-170413055211.pptx

  • 1. 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