não é muito no contexto do forum
mais sei que tem muita gente fera aki…
entao ai vai…
tenho uma tabela com os seguintes dados:
id
nome
data_cadastro
data_alteração
gostaria que a data_cadastro, pegasse a data do servido somente na inserção de um registro e
a data_alteração, pegue a data do servidor sempre que o registro for atualizado
FLwS…
Boa tarde,
Qual servidor de banco de dados esta utilizando? Eu trabalhei somente com PostgreSQL, mas estou colocando um link para funcoes de data do MySQL
http://www.postgresql.org/docs/8.0/interactive/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
[google]postgresql date functions[/google]
[google]mysql date functions[/google]
EDIT: Muito bacana (e util) o botao para pesquisa no google e etc
[]`s
estou usando MySql
estou a procura de uma função ou valor Default para a data
que sempre que atualizado o registro atualize automaticamente a data…
caso nao seja possivel irei fazer no java msm, sem problemas
mas queria saber se tem como deixar isso automatico…
Utilizando as funcoes do banco de dados vc consegue (utilizando triggers)
http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html
De uma pesquisada no google
[]`s
não exatamente…
o CURRENT_TIMESTAMP, só pega a data de inserção…
VLwS
peerless,
Ai depende se ele esta utilizando o campo como TIMESTAMP
Lendo os comentarios da pagina, achei um interessante:
user_created_date
timestamp default CURRENT_TIMESTAMP COMMENT ‘creation timestamp’,
user_updated_date
timestamp default ‘20070101000000’ COMMENT ‘edit timestamp’,
This will work. If you try to set the second timestamp field to ON UPDATE CURRENT_TIMESTAMP it will then report
#1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
It seems to me the function of having both a creation timestamp set once by the default and an edit timestamp set repeatedly on update is NOT SUPPORTED by MySQL.
Ja enfrentou tal situacao?
[quote=renatoes]peerless,
Ai depende se ele esta utilizando o campo como TIMESTAMP
Lendo os comentarios da pagina, achei um interessante:
user_created_date
timestamp default CURRENT_TIMESTAMP COMMENT ‘creation timestamp’,
user_updated_date
timestamp default ‘20070101000000’ COMMENT ‘edit timestamp’,
This will work. If you try to set the second timestamp field to ON UPDATE CURRENT_TIMESTAMP it will then report
#1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
It seems to me the function of having both a creation timestamp set once by the default and an edit timestamp set repeatedly on update is NOT SUPPORTED by MySQL.
Ja enfrentou tal situacao? [/quote]
Hmm. Não! Mas acredito que seja por aí o caminho…
T+