TODAY SQL query..........

J

Jonathan

Hi Everyone,

I want to write (using the DBW) a reports that only shows records created
today, but I am at a loss as to what the SQL should be.

ANy help will be greatly apprectiated

Tia

Jonathan
 
K

Kevin Spencer

It all depends on how you identify records created today. Do you have a
column in the table for it?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
J

Jonathan

Hi Kevin

Thanks for your quick reply

Yes - I have a column in the SQL table called "order_date" which is
populated from a hidden field on the input form so every time a user inputs
an order and submits it to the database the field "order_date" is
automatically populated by this hidden field with the current system date
 
K

Kevin Spencer

Hi Jonathan,

Your SQL Server query would l9ok something like the following:

SELECT * FROM tableName WHERE DateDiff(d, order_date, GetDate()) = 0

What this does is subtract your date column from the current date
(GetDate()), using a Day as the interval (d). If the result is 0, the
order_date is from today.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
Top