At 11:43 AM -0600 1999-12-23, Matthew Vanecek wrote:
>> repett0@stripped writes:
>> > Hi,
>> > I have a field in a table that is type datetime. I was
>>wondering how come
>> > it wont get set to the default(current) time if I don't put a
>>value in it.
>> > That is if I use the web form. If I insert in mysql (not doing
>> > it) it works?
>> > Thanks
>> > Ron
>> > ***
>> > This is not a shameless self plug
>> > http://www.unigeek.org
>> > ***
>> If you want to have a value inserted into datetime column, anytime a
>> row is inserted/ updated, you should use timestamp attribute instead.
>What if you only want to show the time when the record was created?
>TIMESTAMP changes each time the record is updated, correct? It would be
>nice to have a server side ability to just insert the current time when
>a record is first created (oh, say, like using a DEFAULT NOW() or
>Yes, I know, you're gonna say "Do it in the program", which is a really
>stupid response. The more that has to be done from the client/program
>side, the greater the likelihood for invalid/corrupt data. Besides, it
>doesn't seem like it would be a great performance loss to allow that
>type of default.
Yes, it would be nice to say DEFAULT NOW(), but you can't. I think this
is on the To Do (don't quote me), but it hasn't been implemented. I
would guess it's not completely trivial or it would have been done.
Telling people that they are going to give you "a really stupid response"
probably isn't the best way to elicit useful feedback. Re: invalid
or corrupt data, since you're such a brainy guy in comparison to the
rest of us morons, it's no doubt not escaped you that you'd write a function
to return the current timestamp so that you wouldn't have to rewrite
the code every time.
Paul DuBois, paul@stripped