You are here: Re: How can I specify 'NO' as default value for datetime value or convert default value into 'NO' in query? « PHP SQL « IT news, forums, messages
Re: How can I specify 'NO' as default value for datetime value or convert default value into 'NO' in query?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация