Can anyone tell me ...
Clear all

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

Pavan NJ
Posts: 47
 Pavan NJ
Topic starter
(@Pavan NJ)
Joined: 2 years ago

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

1 Reply
Posts: 36
Joined: 2 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)

Leave a reply

Author Name

Author Email

Title *

Preview 0 Revisions Saved