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?

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

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

1 Reply
Sandeep0069
Posts: 36
 Sandeep0069
Guest
(@Sandeep0069)
Eminent Member
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)
Reply

Leave a reply

Author Name

Author Email

Title *

 
Preview 0 Revisions Saved
Share: