another time mystery

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • meltedown

    another time mystery

    In this statement:
    "INSERT INTO logins(accounti d,userid,login, jobdesc)
    values($preacco untid,$userid,N OW(),'$jobdesc' )")

    How do I add an hour to NOW() ?
    I tried NOW+60*60, but it adds 37 minutes, which makes no sense at all.
  • meltedown

    #2
    Re: another time mystery

    meltedown wrote:[color=blue]
    > In this statement:
    > "INSERT INTO logins(accounti d,userid,login, jobdesc)
    > values($preacco untid,$userid,N OW(),'$jobdesc' )")
    >
    > How do I add an hour to NOW() ?
    > I tried NOW+60*60, but it adds 37 minutes, which makes no sense at all.[/color]
    I found a web page that explained it


    "INSERT INTO logins(accounti d,userid,login, jobdesc)
    values($preacco untid,$userid,a dddate(NOW(),in terval 1 hour),'$jobdesc ')");

    Comment

    • Gordon Burditt

      #3
      Re: another time mystery

      >In this statement:[color=blue]
      >"INSERT INTO logins(accounti d,userid,login, jobdesc)
      >values($preacc ountid,$userid, NOW(),'$jobdesc ')")
      >
      >How do I add an hour to NOW() ?[/color]

      adddate(now(), INTERVAL 1 HOUR)

      adddate() and subdate() are very useful functions.
      [color=blue]
      >I tried NOW+60*60, but it adds 37 minutes, which makes no sense at all.[/color]

      What you got makes plenty of sense if you expand it out and treat
      the result AS INTEGERS (not dates). You don't want to add dates
      like this. Carries from seconds to minutes, minutes to hours, hours
      to days, days to months, and months to years don't work right.

      23:30:53 October 4, 2005

      20051004233053 + 3600 = 20051004236653

      Now interpret that as a date, and you get 23:66:53 October 4, 2005 .
      Doesn't look like a valid date, does it? You can also get such nice
      things as October 86, 2005, and nonexistent months.

      Gordon L. Burditt

      Comment

      Working...