Re: Date SELECT with IF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



SELECT
    IF( B.Booking_End_Date != "0000-00-00",
        DATE_FORMAT( B.Booking_End_Date, "%Y-%m-%d" ),
        "N/A"
    ) AS Booking_End_Date
FROM Bookings AS B, etc.

HTH
Ignatius
_________________________
----- Original Message -----
From: "Shaun" <shaun@xxxxxxxxxxxxxx>
To: <php-db@xxxxxxxxxxxxx>
Sent: Thursday, April 15, 2004 7:44 PM
Subject:  Date SELECT with IF


> Hi,
>
> Is it possible to have a clause in a mysql SELECT statement? I would the
> query to display the date except where it equals the default 000-00-00 to
> display n/a or something similar.
>
> For example SELECT DATE_FORMAT(B.Booking_End_Date, \"%Y-%m-%d\") AS
'Booking
> End Date' FROM Bookings (IF Booking_End_Date = '0000-00-00' DISPLAY
'n/a');
>
> I hope this illustrates what I am trying to achieve!
>
> Thanks for your help
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux