Forum Replies Created

Viewing 9 posts - 1 through 9 (of 9 total)

  • RE: Select records form lasthour

    Interesting... now i've deleted old data and inserted again with the same date values as the previous deleted and now it works fine. Really dont now why is that happening.

    Now...

  • RE: Select records form lasthour

    Craig Farrell (2/17/2011)


    Then your code should work. In the MyTable DDL, is [date] a field type of DATETIME, or is it VARCHAR() or something else?

    There's no other reasons that...

  • RE: Select records form lasthour

    Craig Farrell (2/17/2011)


    Can you run this in a separate query window and tell me if you get one, or two, records back?

    IF OBJECT_ID('tempdb..#MyData') IS NOT NULL

    DROP TABLE #MyData

    CREATE TABLE #MyData

    ([Date]...

  • RE: Select records form lasthour

    Craig Farrell (2/17/2011)


    I have my own data, first record was inserted 02/07/2011 11:44:11 PM

    Then please post your actual SQL, as I requested, and we might be able to help.[/quote]

    select *...

  • RE: Select records form lasthour

    Craig Farrell (2/17/2011)


    If you're using my sample data/build, there's no records in the last 14 days then there was in the last hour, so that's correct.

    If you're using your real...

  • RE: Select records form lasthour

    Craig Farrell (2/17/2011)


    Weeks work by weeknumber based off the calendar days, it's not a straight 14 day count. Instead of wk, -2, try using dd, -14.

    Yes, I try to...

  • RE: Select records form lasthour

    Thank you Craig, it works when i use:

    select * from #cdata where cDate >= DATEADD( hour, -1, getdate())

    ...

  • RE: Select records form lasthour

    CREATE TABLE dbo.cData (

    ID bigint NOT NULL IDENTITY(1, 1),

    [Value] float,

    [Date] datetime

    )

    in Date field i...

  • RE: Select records form lasthour

    Andreas Goldman (2/16/2011)


    WHERE [DATE] >= DATEADD(HOUR, - 1, GETDATE())

    hm... this query gets all data from table. My last record was inserted 08/02/2011 11:44:56 PM so

    it must return zero rows because...

Viewing 9 posts - 1 through 9 (of 9 total)