Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mysql timestamp

 
jite eghagha
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey,

I have a problem using timestamp.

if 'A' occurs i wish to set the timestamp to the current time, but if 'B' occurs i wish the timestamp to remain 0.

so i set this code up before the sql command:


I created my table as such:



either way, timestamp is always updated, even if i send a 'null' to the sql coomand for the timestamp column.



 
Scott Selikoff
author
Saloon Keeper
Posts: 4014
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use DATETIME instead, it stores the same data and doesn't have the 'often flaky' default/auto-insert rules.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4014
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jite eghagha wrote:


Also, I'm not a big fan of this code. How about a non-database dependent alternative such as:

jite eghagha wrote:


Granted, you may have a reason to prefer the database time to the application server, but in practice it often doesn't matter.
 
jite eghagha
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you, DATETIME works fine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic