Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2004
    Posts
    4

    Unanswered: now - 10 seconds

    Hi !

    sometimes I am not getting the @@identity

    how can you get the last ID from the last 10 seconds ?

    SELECT TOP 1 myTable.id FROM myTable WHERE myTable.Dates = (Now -10) ORDER BY myTable.id DESC;

    is not working

    thank you

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    you would need something like:
    Now() - (10/(24*60*60))

    ...obviously you could replace (10/(24*60*60)) with a literal whatever it turns out to be.

    your calc is subtracting 10 days.



    be warned: politically-correct coders will insist you you dateadd()

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Oct 2004
    Posts
    4
    you mean Now() -0.00011574074 ?

    it must be posible to do it with something like now(second)-10 ?? no ?

    thanks for helping

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    no!

    now() returns a double (LATER: and does not take parameters)
    days.fractionalDays since (or before) access internally defined zero-day (which happens to be 30th December, 1899 for some bizarre reason)

    the correct way to do this sort of stuff is via the dateadd() function
    dateadd("s", -10, now())

    izy
    Last edited by izyrider; 10-13-04 at 03:05.
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •