Database Design (SQL)

posted by .

I need help creating a query that shows the number of days left before the end of the term. I need the following functions to accomplish this: CONCAT, DAYOFYEAR, NOW. So far I have this for my query:

SELECT CONCAT('There are ',DAYOFYEAR(NOW()),' ',DAYOFYEAR(NOW())) AS `Days Left`;

The result is supposed to say: There are 69 days left before school ends for the spring term!!!

The result I got was: There are 79 79

  • Database Design (SQL) -

    There are a few things to note:
    1. You need to have a date to specify the end of the term, or else SQL has no way to get the answer you want.
    2. The result 79 represents the number of days since January 1st of the year, which correspond to about March 20th.
    3. 79 appeared twice because the expression DAYOFYEAR(NOW()) appeared twice.
    4. Finally, to find the number of days left, you need to subtract one date from the other, something like:
    DAYOFYEAR('2011-06-03')-DAYOFYEAR(NOW())
    Assuming 3rd of June is the last day of the term.

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. Math

    How can I figure the number of days from one date to another?
  2. window 2003 server

    You are the network administrator for a telecommunications company in Rochester, New York. The network consists of two Windows Server 2003 systems and 57 Windows XP Professional systems. Both servers are used as domain controllers. …
  3. Database Design (SQL)

    I ned help creating a query that shows the number of days left before the end of the term. I need the following functions to accomplish this: CONCAT, DAYOFYEAR, NOW. So far I have this for my query: SELECT CONCAT('There are ',DAYOFYEAR(NOW()),' …
  4. Database Design (SQL)

    Hi I need help creating an SQL query to display each faculty member's last name, comma, first name as a CONCATenated element, then their salary as CONCATenated element with a dollar sign and comma. Then, the boss's last name, comma, …
  5. Database Design (SQL)

    Hi I need help creating an SQL query to display each faculty member's last name, comma, first name as a CONCATenated element, then their salary as CONCATenated element with a dollar sign and comma. Then, the boss's last name, comma, …
  6. SQL

    Display a list of all instructors, showing their ID, name, and the number of sections that they have taught. Make sure to show the number of sections as 0 for instructors who have not taught any section. Your query should use an outerjoin, …
  7. databases

    Fernando Cilebra has always ben facinated by skateboards. Fernando has won several contests, both locally and nationally. His interest in skateboards led him to open Fernando's Shop in Denton, Maine. Fernando sells street, trick, and …
  8. Computer Database SQL

    Update the data in the Employees table so that employees with the following managers are listed as working in the following departments: The UPDATE statement in SQL. I cant figure the statement, I keep getting syntax error. Help. ReportsTo …
  9. buissness

    Data Security Password protect the database you created for your individual assignment in Week Three. Create a matrix to indicate the permissions (read, insert, delete, modify) you would grant to different users of your database. Create …
  10. SQL PROGRAMMING INFORMATION SYSTEMS

    In the following SQL query why do they have an independent letter then period then the table name?

More Similar Questions