Likes Likes:  0
Resultaten 1 tot 2 van de 2
Geen
  1. #1
    henq
    [mysql] datum-tijd syntax in insert-query
    Gast
    n/a Berichten
    Berichten zijn liked



    Thread Starter

    [mysql] datum-tijd syntax in insert-query

    Hi,

    Ik wil een datum-tijd instellen van een DATETIME kolom op bijv. 1 uur vanaf
    nu. Ik wil (voor de sport) niet in perl/php programmeren, maar het puur in
    sql doen.

    Ik probeer zoiets als ...

    INSERT INTO mijn_tabel (wek_tijd)
    VALUES (DATE_ADD(NOW(), INTERVAL 3600 SECONDS))

    Maar ik krijg een syntax error. Snapt iemand meer dan ik van die datum/tijd
    functies van mysql? Kan je die allen met SELECT's gebruiken? (alle
    voorbeelden die ik zie zijn met SELECT's).

    ~henq



  2. #2
    Daniel Tryba
    [mysql] datum-tijd syntax in insert-query
    Gast
    n/a Berichten
    Berichten zijn liked



    Thread Starter

    Re: [mysql] datum-tijd syntax in insert-query

    "henq" <henq _ replace 0 by o <hvtijen@h0tmail.c0m>> wrote:
    > Ik probeer zoiets als ...
    >
    > INSERT INTO mijn_tabel (wek_tijd)
    > VALUES (DATE_ADD(NOW(), INTERVAL 3600 SECONDS))
    >
    > Maar ik krijg een syntax error.


    Lees op
    http://www.mysql.com/documentation/m...time_functions

    <q>
    ADDDATE(date,INTERVAL expr type)

    These functions perform date arithmetic. ADDDATE() and SUBDATE() are
    synonyms for DATE_ADD() and DATE_SUB(). In MySQL Version 3.23, you can
    use + and - instead of DATE_ADD() and DATE_SUB() if the expression on
    the right side is a date or datetime column. (See example below.) date
    is a DATETIME or DATE value specifying the starting date. expr is an
    expression specifying the interval value to be added or subtracted from
    the starting date. expr is a string; it may start with a `-' for
    negative intervals. type is a keyword indicating how the expression
    should be interpreted. The following table shows how the type and expr
    arguments are related:

    type value Expected expr format
    SECOND SECONDS
    </q>

    Het lijkt erop dat de seconds uit je expressie geen geldig type is.

    --

    Daniel Tryba


Webhostingtalk.nl

Contact

  • Rokin 113-115
  • 1012 KP, Amsterdam
  • Nederland
  • Contact
© Copyright 2001-2026 Webhostingtalk.nl.
Web Statistics