Forum

Can you help me to ...
 
Share:
Notifications
Clear all

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


Posts: 47
Guest
Topic starter
(@Pavan NJ)
Eminent Member
Joined: 5 years ago

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

1 Reply
Posts: 47
Guest
Topic starter
(@V Gopal)
Eminent Member
Joined: 5 years 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

Leave a reply

Author Name

Author Email

Title *

 
Preview 0 Revisions Saved
Share: