Setting Date with current timestamp

  • I am getting an error saying date is not a current fucntion, I am using the following SQL query:

    INSERT INTO Employees(Rtype, Amount, Refnumber, Color, Date)

    SELECT Rtype, 34, Refnumber, Color, Date(CURRENT_TIMESTAMP)

    FROM Employees

    WHERE Amount=-34 AND Rtype = 'AD';

    Any suggestions?

  • The error is correct... Since you want to use the CURRENT_TIMESTAMP as the DATE column, you need to create a column alias... like this...

     INSERT INTO Employees

            (Rtype, Amount, Refnumber, Color, Date)

     SELECT Rtype, 34, Refnumber, Color, CURRENT_TIMESTAMP AS Date

       FROM Employees

      WHERE Amount = -34 

        AND Rtype  = 'AD'

    Not trying to be condescending, by any means, but this seems a bit like a "newbie" problem... you might want to make a trip by W3Schools.com for a decent SQL Tutorial.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Hi Jeff,

    That is not condescending at all, and I know its pretty obvious that I am a newbie, but that is why I am here in this forum with all you experts....so I can learn.....from the best (Smile)

    Thank you for the link there I will check it out, I found one link that has a tutorial where you can actual practice with queries, but there is not a lot of statements you can do with it. But thank you for looking out, have a good night.

    Mark

  • Thanks for the feedback and for not taking it the wrong way, Mark.    You have exactly the right frame of mind to do very well in all of this... It'll be my pleasure to help whenever I can.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply