0

I've a table product(prodID,stock,createdDate type DATETIME )

Wanna find all record from table for the current date

Thanks

Myaw
  • 61
  • 9
  • Sounds like you want to build a `WHERE` clause against the `createdDate` column in your `SELECT` statement. Have you tried doing that? Did it work? – David Mar 03 '13 at 13:02

1 Answers1

1

This rounds to the current date:

...
WHERE createdDate >= dateadd(dd, datediff(dd, 0, GetDate()), 0)
  • GetDate returns the current datetime
  • datediff(dd, 0, GetDate()), 0) returns the days from the first date until now
  • dateadd(dd ads ... these days to the first date, so we get the current date without time
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
  • it work , Thank you vm, What if I want to find all record for date X? – Myaw Mar 03 '13 at 13:16
  • @Myaw: `WHERE createdDate BETWEEN dateadd(dd, datediff(dd, 0, @startDate), 0) AND dateadd(dd, datediff(dd, 0, @endDate), 0)` – Tim Schmelter Mar 03 '13 at 13:17
  • this query to find all records between two date so what If I want show all records for @date = X ? – Myaw Mar 03 '13 at 13:35