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?

2 Posts
1 Users
0 Likes
274 Views
Pavan NJ
Posts: 47
 Pavan NJ
Guest
Topic starter
(@Pavan NJ)
Eminent Member
Joined: 2 years ago

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

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