Question

In: Computer Science

Write a query to return the date and day of the week of the first day...

Write a query to return the date and day of the week of the first day of the month two years from today.

If today is 10/16/20, then the expect output is 10/01/2022 and the day of the week is thursday.

I am using postgresql.

Solutions

Expert Solution

first of all 10/01/2022 ---> oct /01/2022   is saturday. not thursday.

try the below query

----------------------------------------------

with daynumber as (select date_trunc('month', current_date + interval '2 years')as date,extract(isodow from date_trunc('month', current_date + interval '2 years')) -  0 daynumber ),
week as(select CASE 
         WHEN daynumber.daynumber =1 THEN 'Monday'
         WHEN daynumber.daynumber=2 THEN 'Tuesday'
         WHEN daynumber.daynumber=3 THEN 'Wednesday'
         WHEN daynumber.daynumber=4 THEN 'Thursday'
         WHEN daynumber.daynumber=5 THEN 'Friday'
         WHEN daynumber.daynumber=6 THEN 'Saturday'
         WHEN daynumber.daynumber=7 THEN 'Sunday'
     ELSE 'other'
   END from daynumber ) 
 select *from daynumber,week;

-----------------------------------

output


Related Solutions

What day of the week is a given date? i.e. On what day of the week...
What day of the week is a given date? i.e. On what day of the week was 5 August 1967? if it is given that 1 January 1900 was a tuesday Write a function is leap() which takes 1 input argument, an integer representing a year, and returns True if the year was a leap year, and False if it was not. .Then, write a function days_since() which takes 3 input integers day, month, year, representing a date (after 1st...
1. Write a query to: a. select data from INVOICES table as follows: Invoice date in...
1. Write a query to: a. select data from INVOICES table as follows: Invoice date in MM/DD/YYYY format Invoice Date in DD-Mon-YYYY format Invoice Total rounded to the nearest dollar Note: you can alias columns as you sit fit b. select data from VENDORS table as follows: Vendor Name Concatenate Vendor Name with the string ‘s Address Concatenate Vendor City, Vendor State and Vendor Zip Code (alias this) Your output should look like this (this is just an example of...
USE PYTHON to find out What day of the week is a given date? i.e. On...
USE PYTHON to find out What day of the week is a given date? i.e. On what day of the week was 5 August 1967? if it is given that 1 January 1900 was a tuesday Write a function is_leap() which takes 1 input argument, an integer representing a year, and returns True if the year was a leap year, and False if it was not. .Then, write a function days_since() which takes 3 input integers day, month, year, representing...
Complete the code so that it can convert the date to day of week using python,...
Complete the code so that it can convert the date to day of week using python, the code should pass the doctest def convert_datetime_to_dayofweek(datetime_string): """ This function takes date in the format MON DAY YEAR HH:MM(PM/AM) and returns the day of the week Assume input string is UTC    >>> convert_datetime_to_dayofweek('Jun 1 2005 1:33PM') 'Wednesday' >>> convert_datetime_to_dayofweek('Oct 25 2012 2:17AM') 'Thursday' """ # code goes here
1. How do I write a query that displays the name (concatenate the first name, middle...
1. How do I write a query that displays the name (concatenate the first name, middle initial, and last name), date of birth, and age for all students? Show the age with no decimal places, and only include those students who are 21 or older. Order by age, as shown below: (Hint: Use the TRUNC function. The ages may be different, depending on the date that the query is run.) SELECT S_FIRST || ' ' || S_MI || ' '...
Write a c++ program that asks the user for a date (Month and Day only) and...
Write a c++ program that asks the user for a date (Month and Day only) and displays the season in this day.The program asks then the user if he needs to enter another date, if he answers with ’Y’ or ’y’, the programwill take another date from the user and displays the season in this day.The program will keep repeating this until the user enters a character different than ’Y’ and ’y’.•Fall starts in September 21st•Winter starts in December 21st•Spring...
Write a query to display the columns listed below. For each customer the query should show...
Write a query to display the columns listed below. For each customer the query should show the current system date, the current day (when you do the problem the date and day will be different), the number of characters in the member last name, the last date the customer rented a video and how many total videos the person rented. /* Database Systems, 9th Ed., Coronel/MOrris/Rob */ /* Type of SQL : MySQL */ CREATE SCHEMA IF NOT EXISTS TINY_VIDEO;...
Date - month: int - day: int - year: int +Date() +Date(month: int, day: int, year:...
Date - month: int - day: int - year: int +Date() +Date(month: int, day: int, year: int) +setDate(month: int, day: int, year: int): void -setDay(day: int): void -setMonth(month: int): void -setYear(year: int): void +getMonth():int +getDay():int +getYear():int +isLeapYear(): boolean +determineSeason(): string +printDate():void Create the class Constructor with no arguments sets the date to be January 1, 1900 Constructor with arguments CALLS THE SET FUNCTIONS to set the Month, then set the Year, and then set the Day - IN THAT ORDER...
what should a teacher done in the first day and week of the school? why its...
what should a teacher done in the first day and week of the school? why its important
PYTHON PROGRAM: Write a program that determines the day of the week for any given calendar...
PYTHON PROGRAM: Write a program that determines the day of the week for any given calendar date after January 1, 1900, which was a Monday. This program will need to account for leap years, which occur in every year that is divisible by 4, except for years that are divisible by 100 but are not divisible by 400. For example, 1900 was not a leap year, but 2000 was a leap year.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT