Question

what is the syntax to calculate age in sql using birth_date column and todays date

what is the syntax to calculate age in sql using birth_date column and todays date

0 0
Add a comment Improve this question Transcribed image text
Answer #1

SQL Syntax -

DECLARE @dateOfBirth datetime

SET @dateOfBirth='1995-09-17 00:00:00'

SELECT DATEDIFF(hour,@dateOfBirth,GETDATE())/8766 AS AgeYears

Screenshots -

Add a comment
Know the answer?
Add Answer to:
what is the syntax to calculate age in sql using birth_date column and todays date
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a query in SQL to list the following information of the artists in movie industry....

    Write a query in SQL to list the following information of the artists in movie industry. Limit this information to only 5 artists. Sort the information by age descending order.          Full name : first name and last name separated by space          Age: Current age          Address: State that he resides          Contact number: Phone number This is from an artist table, where first_name, last_name, contact_no, address, birth_date are the fields in the table. Birth date in the table...

  • Write an SQL statement to join EMPLOYEE, ASSIGNMENT, and PROJECT using the JOIN ON syntax. Run...

    Write an SQL statement to join EMPLOYEE, ASSIGNMENT, and PROJECT using the JOIN ON syntax. Run this statement. Write an SQL statement to join EMPLOYEE and ASSIGNMENT and include all rows of EMPLOYEE in your answer, regardless of whether they have an ASSIGNMENT. Run this statement. I have been working on these two questions for the last 3 hours and I cannot get Microsoft Access 2016 to Run them without an error message coming up.

  • How do you calculate the asked Price? Todays date: 08/30/2019 Maturity: 08/31/2019 Coupon: 1 Bid: 99.3100...

    How do you calculate the asked Price? Todays date: 08/30/2019 Maturity: 08/31/2019 Coupon: 1 Bid: 99.3100 Asked: 99.314 Change -0.002 Asked Yield: 6.83

  • Part II: Give the exact SQL syntax for the following (use the included table where necessary)....

    Part II: Give the exact SQL syntax for the following (use the included table where necessary). 5pts ea. MEDIA TABLE FILE NAMES FILE LOCATION FILE ORDER DBS130.mkv -Desktop DBS131.mkv -Desktop 2 DBS129.mkv - Desktop null 11. When is a composite key necessary? 12. How do I change a column's name and data type in the above table? 13. How do add a column to the above table? 14. Select an from the above table in the following order: 3rd column...

  • How can we create table? What are the various data types available using sql What are...

    How can we create table? What are the various data types available using sql What are the various constraints that you can create. What is the difference between table level constraints and column level constraints? table create with SQL Using oracle.

  • If a column has the IDENTITY property configured in a SQL Server database, what will happen...

    If a column has the IDENTITY property configured in a SQL Server database, what will happen during an insert statement without supplying a value for that column? Question options: Nothing will happen It will throw an error message It will create a new unique number It will set that column's value to NULL

  • [IN SQL] New to working in SQL and I need to make a database called HAFH....

    [IN SQL] New to working in SQL and I need to make a database called HAFH. I am trying to create tables for the database with the information from the photo above but having issues. I am looking for the syntax that successfully creates these tables, and references each other. I know each table has to be made in a specific order, and that is what I am struggling with. INSPECTOR InsID InsName INSPECTING InsID (FK) BuildingID (FK) Date Last...

  • WRITE A SQL QUERY SQL SERVER Write a SELECT statement that returns one column from the...

    WRITE A SQL QUERY SQL SERVER Write a SELECT statement that returns one column from the Customers table named FullName that joins the LastName and FirstName columns. --       Format this column with the last name, a comma, a space, and the first name like this: --       Doe, John --       Sort the result set by last name in ascending sequence. --       Return only the contacts whose last name begins with a letter from M to Z. --  ...

  • I keep getting this error "You have an error in your SQL syntax; check the manual...

    I keep getting this error "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 4" line 4 is the "Genre char(20) not null," any help or guidance would be lovely create table Games      (gameid int not null auto_increment primary key,       title varchar(100) not null,       Genre char(20) not null,       year_released int not null);      insert into Games(title, Genre,...

  • What is the correct expression to find someone's age if you only have a date of...

    What is the correct expression to find someone's age if you only have a date of birth column called "birthdate". Question options: getdate() - birthdate datediff(year, birthdate, getdate()) year(getdate() - birthdate) datediff(year, getdate(), birthdate)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT