Concept explainers
Explanation of Solution
a.
MONTHS_BETWEEN ():
The function “MONTHS_BETWEEN” is used to return the number of months between dates. If the “date1” is future than “date2”, then the result is positive. If the “date1” is previous than “date2”, then the result is negative.
Syntax:
MONTHS_BETWEEN (DATE1, DATE2)
Example:
Consider an example for the “MONTHS_BETWEEN ()” function in Oracle is as follows:
SELECT MONTHS_BETWEEN (TO_DATE ('11-03-2019', 'MM/DD/YYYY'), TO_DATE ('06-16-2014', 'MM/DD/YYYY')) "Months" FROM DUAL;
Explanation:
The above query is used to display the difference between “11-03-2019” and “06-16-2014” dates.
Difference between “CURRENT_DATE” and “SYSDATE” function:
“CURRENT_DATE” function | “SYSDATE” function |
The “CURRENT_DATE” function is used to return the current date. Depending on user input (numeric or string), it will return the current date in “YYYY-MM-DD” OR “YYYYMMDD” format. | The “SYSDATE” function is used to return the current date and time for the |
The syntax for “CURRENT_DATE” is “CURRENT_DATE ();” | The syntax for “SYSDATE” is “SYSDATE ();” |
Functions in Oracle, SQL Server and Access:
“No”, the “MONTHS_BETWEEN ()” function is not available in SQL Server, and Access, but other functions are present in the Oracle, SQL Server, and Access.
- The “DATEDIFF” function can be used to return the number of months given a starting date and an ending date in the SQL Server.
“MONTHS_BETWEEN ()” in Oracle:
- The function “MONTHS_BETWEEN” is used to return the number of months between dates.
- Syntax is “MONTHS_BETWEEN (DATE1, DATE2)”
- Example is “SELECT MONTHS_BETWEEN (TO_DATE ('11-03-2019', 'MM/DD/YYYY'), TO_DATE ('06-16-2014', 'MM/DD/YYYY')) "Months" FROM DUAL;”...
Explanation of Solution
b.
Difference between “NOW ()” and “DATE ()” function:
“NOW ()”function | “DATE ()” function |
The “NOW ()” function is used to return the current date and time in Access... |
Trending nowThis is a popular solution!
Chapter 8 Solutions
A Guide to SQL
- Write the SQL code that will change the PROJ_NUM to 14 for employees who were hired before January 1, 1994, and whose job code is at least 501. (You may assume that the table will be restored to its condition preceding this question.)arrow_forwardWrite the SQL code to delete the row for William Smithfield, who was hired on June 22, 2004, and whose job code is 500. (Hint: Use logical operators to include all of the information given in this problem.)arrow_forwardReview the data for the TRIP table in Figure 1-5 in Chapter 1 and then review the data types used to create the TRIP table in Figure 3-39. Suggest alternate data types for at least two fields that currently have the CHAR data type and at least two fields that currently have the DECIMAL data type. Create but do not execute the SQL command to create the TRIP table using these alternate data types.arrow_forward
- Write the SQL code to calculate the ASSIGN_CHARGE values in the ASSIGNMENT table in the Ch07_ConstructCo database. (See Figure P7.1.) Note that ASSIGN_CHARGE is a derived attribute that is calculated by multiplying ASSIGN_CHG_HR by ASSIGN_HOURS.arrow_forwardSQL includes many numerical functions. Two of these functions are FLOOR and CEIL. Use the Internet to research these functions. Are the functions available in Oracle, SQLServer, and Access? Write a paragraph that discusses what the functions do and anydifferences and/or similarities between the functions in Oracle, SQL Server, and Access.Then perform the following tasks: a. Solmaris Condominium Group would like to know the impact of discounting its condofees by 3 percent. Write an SQL statement in Oracle that displays the condo ID, unitnumber, discounted condo fee, discounted condo fee with the CEIL function, anddiscounted condo fee with the FLOOR function. b. Based on your research, will the values in the three columns vary? If so, how? Usethe condo with the ID of 1 to explain your answer. Be sure to cite your references.arrow_forward
- A Guide to SQLComputer ScienceISBN:9781111527273Author:Philip J. PrattPublisher:Course Technology PtrDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781305627482Author:Carlos Coronel, Steven MorrisPublisher:Cengage Learning
- Database Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781285196145Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos CoronelPublisher:Cengage Learning