Forum

Can you help me to ...
 
Notifications
Clear all

Can you help me to Write a SQL Query to Get people born last 7 days excluding Today?


Pavan NJ
Posts: 47
 Pavan NJ
Topic starter
(@Pavan NJ)
Joined: 1 year ago

How to write a SQL Query to Get people born last 7 days excluding Today?

1 Reply
Pavan NJ
Posts: 47
 Pavan NJ
Topic starter
(@Pavan NJ)
Joined: 1 year ago

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.

Reply
Share: