• tnnelzo (6/20/2013)


    Hello lowell,

    Here is the querry i run everyday,

    Select day(b.date_entered)Day_D, sum(a.despatched_qty), sum(a.val) from scheme.dgtable1 a, scheme.dntable3 b

    where a.order_no = b.order_no

    and a.product like 'Machines%'

    and b.date_entered >=cast('2011-05-01 00:00:00.000' as datetime)

    and b.date_entered < cast('2011-05-24 00:00:00.000'as datetime)

    group by day(b.date_entered)

    order by day(b.date_entered)

    so i have been changing the date depending on the current date so it is pretty challenging because it has to run and give results of stats of the previous day......please help me do this....

    it can still be done, but how are the dates to calculated?

    think of it compared to today:

    if today is 06/20/2013, and i want the first day of the month, i can use

    select DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)

    is it from the first day of this month? the previous month?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!