|
Posted by J.O. Aho on 10/05/51 11:46
talthen.z-serwera.o2@nospam.pl wrote:
>> When I fill datetime field with empty string I get "0000-00-00 00:00:00"-
>> it's fine, but when I display it I want the string 'NO' instead of these
>> zeros.
>> So... how can I specify 'NO' as default value for datetime value?
>> OR
>> How can I show dates and replace all dates="0000-00-00 00:00:00" with
>> 'NO'?
>>
>> All I have made is-
>> SELECT 'NO' FROM `tab` WHERE SUBSTRING(date,0,1)='0'
>> But I dunno how do add showing non-zero dates... in one query.
>
> SELECT IF (SUBSTRING(`date`,1,1)='0','NO',`date`) from `tab`;
>
> Works fine, but... is there a way to set the default value to NO?
No, as 'NO' isn't a valid datetime. If you want to be able to mix, you would
need to switch to varchar or other datatype that aren't "strict", but at the
same time you loose functionality as the data will be treated as text and will
not be sorted in the same way.
//Aho
Navigation:
[Reply to this message]
|