Loading ...
Sorry, an error occurred while loading the content.

MySQL - trying to insert date only.

Expand Messages
  • zeshanism
    my $sql = qq~ INSERT INTO $table(id, job, name, type, chars, trans, tim) VALUES ( , $job , $name , $type , $chars , $trans , now()) ~; Only now()
    Message 1 of 2 , Oct 31, 2004
    • 0 Attachment
      my $sql = qq~ INSERT INTO $table(id, job, name, type, chars, trans,
      tim) VALUES ('', "$job", "$name", "$type", "$chars", "$trans", now())
      ~;

      Only now() function is working for me in the script, this inserts
      the time as well with date. I need Date only, so I found a way
      around it to define 'tim' as SMALLINT(10) so it only gets YYYY-MM-
      DD, dirty trick.

      But anyone can tell me what should I use to insert DATE only? what
      should I replace now() with? as I want to define the column 'tim' as
      DATE rather SMALLINT(10).

      Thanks for any help.

      Zeshan.
    • Riviere Informatique SARL
      Use curdate() instead of now() Regards, Steven.
      Message 2 of 2 , Nov 1, 2004
      • 0 Attachment
        Use curdate() instead of now()

        Regards,
        Steven.

        zeshanism wrote:

        >my $sql = qq~ INSERT INTO $table(id, job, name, type, chars, trans,
        >tim) VALUES ('', "$job", "$name", "$type", "$chars", "$trans", now())
        >~;
        >
        >Only now() function is working for me in the script, this inserts
        >the time as well with date. I need Date only, so I found a way
        >around it to define 'tim' as SMALLINT(10) so it only gets YYYY-MM-
        >DD, dirty trick.
        >
        >But anyone can tell me what should I use to insert DATE only? what
        >should I replace now() with? as I want to define the column 'tim' as
        >DATE rather SMALLINT(10).
        >
        >Thanks for any help.
        >
        >Zeshan.
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.