Jul 28, 2020 7:03 am
How to write a SQL Query to Get people born last 7 days excluding Today?
1 Reply
Jul 28, 2020 7:11 am
You can use the below query to achieve this People born last 7 days excluding today.
Select Name, DateOfBirth, CAST(DateOfBirth as Date) as [DatePart]
From Employees
Where CAST(DateOfBirth as Date)
Between
DATEADD (Day,-7, CAST(GETDATE() as Date)) AND DATEADD (Day,-1, CAST(GETDATE() as Date))
Used Get Date () function to avoid timestamp.