MSSQL where date=today


/ Published in: SQL
Save to your folder(s)

This is the best method for querying a table to get data where a date column needs to equal today:


Copy this code and paste it in your HTML
  1. -- edit tbl.datecolumn to reflect required column
  2.  
  3. WHERE tbl.datecolumn >= DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0) AND tbl.datecolumn < DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 1)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.