Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I was wishing to seek some advice on how I can accomplish a task I came into. I have a MySQL database that has a "last updated" column and I have it set to TIMESTAMP so that MySQL automatically updates the field when database has been updated.

However, I also have a cron job that runs a perl script I made that updates the same exact database with the "last updated" column. Therefore, everytime the cron job runs daily, then the last updated column will also be automatically updated. The problem is that I want the last updated value to be the last date the database has been edited phsyically by a data operator. The database btw stores Notes that requires a last udpated field to show the last edit.

So to resolve this, I may just have Perl automatically keep track of the updated date. Instead of having MySQL automatically do it, I will insert a code that generates a data value so I can manually store it in the edit function of my script.

I want a date value to me in the following type of format:

Tue Jan 3 2004

I have already spent the last 2 hours trying to figure this out, but still having trouble. Any help will greatly be appreciated.

Thanks for taking your time to read this,

Alexa

Replies are listed 'Best First'.
Re: Perl to create Date modified value
by Aristotle (Chancellor) on Jan 30, 2006 at 23:38 UTC

    Simply “update” the field explicitly to its previous value.

    UPDATE foo SET bar = 'baz', last_update = last_update WHERE id = 42

    Makeshifts last the longest.

Re: Perl to create Date modified value
by idle (Friar) on Jan 31, 2006 at 06:41 UTC