By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,466 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

Inserts that auto-record a timestamp ??

P: n/a

Folks,

I have several tables which I would like to record when a record has
been inserted or updated (say, for example, using the unix timestamp).

Is there a method whereby on every insert or update, that I can have a
column automatically assigned a date value?

My guess is no - but I thought I'd ask before I re-invent the wheel by
re-editing my code.... All help, via the newsgroup would be greatly
appreciated...

Thanks
Randell D.
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Add a column called timestamp (or whatever) using data type 'timestamp'.

That's it.

Every time a record is inserted/updated this field will be updated with
the current date/time (from the server).

Regards,

Mike Argy
Custom Office Solutions
and UNIX/Windows Applications

On Sat, 29 Jan 2005 07:30:06 +0000, Randell D. wrote:

Folks,

I have several tables which I would like to record when a record has
been inserted or updated (say, for example, using the unix timestamp).

Is there a method whereby on every insert or update, that I can have a
column automatically assigned a date value?

My guess is no - but I thought I'd ask before I re-invent the wheel by
re-editing my code.... All help, via the newsgroup would be greatly
appreciated...

Thanks
Randell D.


Jul 23 '05 #2

P: n/a
"Mike A" <mi**@nowhere.com> wrote in message
news:pa****************************@nowhere.com...
Add a column called timestamp (or whatever) using data type 'timestamp'.

That's it.

Every time a record is inserted/updated this field will be updated with
the current date/time (from the server).

Regards,

Mike Argy
Custom Office Solutions
and UNIX/Windows Applications

On Sat, 29 Jan 2005 07:30:06 +0000, Randell D. wrote:

Folks,

I have several tables which I would like to record when a record has
been inserted or updated (say, for example, using the unix timestamp).

Is there a method whereby on every insert or update, that I can have a
column automatically assigned a date value?

My guess is no - but I thought I'd ask before I re-invent the wheel by
re-editing my code.... All help, via the newsgroup would be greatly
appreciated...

Thanks
Randell D.


Just to follow up this answer, you do not need to perform any time/date
functions in your code to do this either. Simply leave that field out of
your UPDATE/INSERT statement and MySQL will automatically update the field
on it's own.

Norm
--
FREE Avatar hosting at www.easyavatar.com
Jul 23 '05 #3

P: n/a
Norman Peelman wrote:
"Mike A" <mi**@nowhere.com> wrote in message
news:pa****************************@nowhere.com...
Add a column called timestamp (or whatever) using data type 'timestamp'.

That's it.

Every time a record is inserted/updated this field will be updated with
the current date/time (from the server).

Regards,

Mike Argy
Custom Office Solutions
and UNIX/Windows Applications

On Sat, 29 Jan 2005 07:30:06 +0000, Randell D. wrote:

Folks,

I have several tables which I would like to record when a record has
been inserted or updated (say, for example, using the unix timestamp).

Is there a method whereby on every insert or update, that I can have a
column automatically assigned a date value?

My guess is no - but I thought I'd ask before I re-invent the wheel by
re-editing my code.... All help, via the newsgroup would be greatly
appreciated...

Thanks
Randell D.


Just to follow up this answer, you do not need to perform any time/date
functions in your code to do this either. Simply leave that field out of
your UPDATE/INSERT statement and MySQL will automatically update the field
on it's own.

Norm

Mike / Norm,

Luvely Juvely - Many thanks for that!

Cheers
Randell D.
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.