Forum

How to Write a SQL ...
 
Share:
Notifications
Clear all

How to Write a SQL Query to get all people born between Yesterday and Today


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

I want to write a SQL to get all people born between Yesterday and Today. Any help?

1 Reply
Posts: 36
Guest
(@Sandeep0069)
Eminent Member
Joined: 4 years ago

Hi, you can use the below query to get all people born between Yesterday and Today from the employee table.

Since it is a query related to Date function you can use DATEADD and then compare two dates. 

   Select Name, DateOfBirth, CAST(DateOfBirth as Date) as [DatePart]
 
               From Employees
                             
                   Where  CAST(DateOfBirth as Date)
                       
                          Between 
 
                              DATEADD (Day,-1, CAST(GETDATE() as Date)) AND  CAST(GETDATE() as Date)
Reply

Self Learning Video Tutorials - Software Course

Leave a reply

Author Name

Author Email

Title *

 
Preview 0 Revisions Saved
Share: