• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 423
  • Last Modified:

Tsql how to compare only date part?

Hi, I want to select from a table where the datetime column's date part equals to yesterday's date look something like this
      SELECT emailAddress from dbo.Patients
      where DateCreated = DateTime.Today - 1
need help with the where condition code.  Thank you.
0
lapucca
Asked:
lapucca
1 Solution
 
Patrick MatthewsCommented:
SELECT emailAddress from dbo.Patients
      where DateCreated >= DATEADD(d, -1, CONVERT(datetime, CONVERT(varchar, GETDATE(), 102)))
AND DateCreated < CONVERT(datetime, CONVERT(varchar, GETDATE(), 102))
0
 
simpsolCommented:
SELECT emailAddress
  FROM dbo.Patients
WHERE DateDiff( 'dd', DateCreated, GetDate() - 1) = 1

0
 
lapuccaAuthor Commented:
Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now