Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. SQL Server
  3. Question
SQL Server

How to extract data between yesterday and today?

Asked by Behailu Jul 12, 2021 2.2K views 1 answer
Share

About this question

I have a column called create date of a DateTime datatype. I want to extract data between today and yesterday. select * from table1(no lock) where createdate ='2018-06-01' --not getting any output I want something like this:


select * from table1(no lock) where createdate between '2018-06-01' and '2018-06-02' Rather than hard coding the date, I need between dateadd(d,-1,getdate()) and getdate(), but getdate() gives current timestamp. How can I search for the whole day like 2018-06-02 rather than 2018-06-02 02:12:13.423?



Your answer

1 Answer

More SQL Server discussions