Forum

Can anyone tell me ...
 
Share:
Notifications
Clear all

Can anyone tell me How to Write a SQL Query to get all people born on Yesterday?


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

How to achieve this SQL Query to get all people born on Yesterday

1 Reply
Posts: 36
Guest
(@Sandeep0069)
Eminent Member
Joined: 4 years ago
 
Let us do some workaround to achieve this.
   
Select (GETDATE)   Will give us the current Date with the timestamp
 
      To Avoid timestamp we can use CAST Function
 
        Select CAST(GETDATE() as Date) will give us the date without a timestamp. 
 
  
  Final Query Query
 
        Select DATEADD(Day,-1,CAST(GETDATE() as Date)) as [Datepart]
   
                From Employees
 
                     Where CAST(DateOfBirth as Date) = DateADD(Day,-1, CAST(GETDATE() as DATE)
Reply

Self Learning Video Tutorials - Software Course

Leave a reply

Author Name

Author Email

Title *

 
Preview 0 Revisions Saved
Share: