Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Posts
    6

    Unanswered: date and time stamp a changed row

    Hi,

    I am about to declare a table with 20 columns.

    How do I create 4 more columns:
    1. current Time
    2. current Day of the month
    3. current Month
    4. current Year

    Such that:
    a. These 4 columns are not editable by the user.
    b. Whenever a row is updated/inserted/replace/etc. then
    these 4 columns in that row are automatically updated
    by the system accordingly.

    Thanks.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I don't think that MySQL can do that yet.

    -PatP

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    a. what do you mean by "not editable by the user"? which user?

    b. combine all 4 into 1 timestamp column, and make it the first one in the table, and the system will automatically update it just as you want -- and when you want the pieces (time, day, month, year) just use the appropriate functions
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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