Subject Re: [firebird-support] Server Date and time
Author Thomas Steinmaurer
Hi,

> I have a client-server application and would like to add a new feature
> that requires the following procedure:
>
> When a client click a button, the server (MySql) generates a new
> record in the database and updates the field ACTUAL_DATE with the
> server's date and time (NOT the client's). Do I have to use
> triggers/stored procedures?

Yes, but not necessarily in case of an INSERT INTO statement.

Use a DEFAULT declaration at field level which will be used when the
field is omitted in field list of an INSERT INTO statement.

Are you using MySQL or is your server simple called MySql? ;-)

> Note that there is a possibility that the client receive the server's
> Date and Time before creation of the new record, and then he (client)
> send an SQL creating and updating the field. In this case is it
> possible to write an SQL expression requiring the server date and time?

Use CURRENT_TIMESTAMP for getting the server's date/time.

For instance:

INSERT INTO (datetimecolumn) values (CURRENT_TIMESTAMP)

or

UPDATE ... SET datetimecolumn = CURRENT_TIMESTAMP WHERE ...



--
Best Regards,
Thomas Steinmaurer
LogManager Series - Logging/Auditing Suites supporting
InterBase, Firebird, Advantage Database, MS SQL Server and
NexusDB V2
Upscene Productions
http://www.upscene.com