Link to home
Start Free TrialLog in
Avatar of Curtis Long
Curtis LongFlag for United States of America

asked on

SQL 2008 R2 Current Date

I run this query to give me all the culls we have since 8-1-2012

SELECT     Ticket_Number, Time_In, Time_Out, Customer, Commodity, Driver, Lot, Gross, Tare, Field_Id, Truck_Id
FROM         dbo.[Transaction]
WHERE     (Commodity = 'CULLS') AND (Time_In >= CONVERT(DATETIME, '2012-08-01 00:00:00', 102))

How can I change this soi instead it would deliver all CULLS for the current date only??
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
WHERE Commodity = 'CULLS'
   AND Time_In >= CAST(GETDATE() as date)

-- i dont use the cast(time_in as date)
Avatar of Curtis Long

ASKER

Thanks so much!!

One other question.....

What would I add if I wanted it to be current date minus one and minus two etc??
>What would I add if I wanted it to be current date minus one and minus two etc??
need to use dateadd function

select dateadd (mm, -1, getdate() )  --will subtract 1 minutes  from curent datetime