Question
DATE FUNCTIONS : 1) Which repairs have been made since January 1st of 2014? List slRepair.RepairID, slRepair.RepairDate, and slRepair.Description where slRepair.RepairDate is after or on
DATE FUNCTIONS :
1) Which repairs have been made since January 1st of 2014? List slRepair.RepairID, slRepair.RepairDate, and slRepair.Description where slRepair.RepairDate is after or on '2014-01-01'. You can use the date value exactly as given above. Order the list by slRepair.RepairDate in ascending order.
2) List slGasPurchase.GasPurchaseID, slGasPurchase.PurchaseDate, and slGasPurchase.CostPerGallon for gas purchases before '2012-12-31'. Order the list by slGasPurchase.PurchaseDate in ascending order.
3) List slRepair.RepairID, slRepair.RepairDate, and slRepair.Description where slRepair.RepairDate is after or on '2012-01-01' and before '2012-04-01'. Use the BETWEEN operator. Order the list by slRepair.RepairDate in ascending order.
4) List slGasPurchase.GasPurchaseID, slGasPurchase.PurchaseDate, and slGasPurchase.CostPerGallon for gas purchases after or on '2011-06-01' and before '2011-08-01'. Order the list by slGasPurchase.PurchaseDate in ascending order.
5) Assume that gas should be used within 30 days of purchase. At what day in the future should gas be used for data in slGasPurchase? List slGasPurchase.GasPurchaseID, slGasPurchase.PurchaseDate, and ExpirationDate for all purchases in slGasPurchase. The attribute ExpirationDate uses the DATEADD() function to add 30 days to slGasPurchase.PurchaseDate. Order the list by slGasPurchase.PurchaseDate in ascending order.
6) Assume work done in slRepair comes with a one year warrenty. Derive the warrenty expiration date for all repairs in slRepair. list slRepair.RepairID, slRepair.RepairDate, and WarrExp for all repairs. The attribute WarrExp uses DATEADD() to add one year to slRepair.RepairDate. Order the list by slRepair.RepairDate in ascending order.
7) Derive the duration of trip for TripID = 6 in minutes. List slTrip.TripID, slTrip.TripStart, slTrip.TripEnd, and Duration for TripID = 6. Use the DATEDIFF() function to compute the difference (Duration) between slTrip.TripStart and slTrip.TripEnd.
8) Show gas purchases for the months of January and May for all years in slGasPurchase. list slGasPurchase.GasPurchaseID, slGasPurchase.PurchaseDate, and slGasPurchase.CostPerGallon for purchases made in the months of January and May. Use DATEPART() to retrieve rows for the MONTHs of January (1) and May (5).
9) List slTrip.TripID, slTrip.TripStart, and slTrip.WaterTemp for trips during the month of June (6) and the year 2014. Use DATEPART() to retrieve rows for the MONTH of June (6) and YEAR 2014. Order the list by slTrip.TripID in ascending order.
10) List slRepair.RepairID, slRepair.RepairDate, RepairMonth, RepairYear, and slRepair.SupplierID for repairs with SupplierID = 1518 and year 2010. Rather than DATEPART(), use the MONTH() and YEAR() functions to produce the correct output. Order the list by slRepair.RepairDate in ascending order.
11) List TripMonth and slTrip.WaterTemp for water temperatures between 80 and 85 degrees. Use MONTH() to produce the attribute TripMonth. Order the list by MONTH() in ascending order
12) Derive the time in months that have elapsed since a given repair was performed. List slRepair.RepairID, slRepair.RepairDate, CurrentDate, and RepairLen for RepairID = 1421; The attribute CurrentDate is produced using CONVERT(DATE, GETDATE()). Use the DATEDIFF() function to compute the difference (RepairLen) between slRepair.RepairDate and the current date, GETDATE().
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started