SQL PRACTICE: SQL SERVER - DATEADD Function
Q12. Find the join date of employees if they join after 2 weeks of the hire date? N.B: I am using the following: Database: MSSQL SQL Dialect: T-SQL Consider below table (Sql_data) as a source data. select * from Sql_data; Table 1. Source Data -- Find the join date of employees select empid, FirstName, LastName, DOB, Hire_date, DATEADD(WK, 2, Hire_date) as Join_date, Salary from Sql_data; Table 2. Join Date Explanation : DATEADD function adds a number to a datepart and returns a modified value based on a specified datepart (Year, Month, Week, Day …..etc...). Syntax: DATEADD (datepart, NumberToAdd, Date) Parameters: datepart - It is part of the date to which the dateadd () function will add a number. It can be Year(YY, YYYY), Quarter(QQ, Q), month(MM,M), day(DD, D), …..etc.... In our case, we are going to use Week (WK) NumberToAdd - It is an ...