UNIXTIME and ISNULL

mnunan

Registered User.
Local time
Today, 08:32
Joined
Apr 22, 2013
Messages
13
Hello

I have the following query running from a MySql database and need a little help please.

I need to return a 0 or just blank field if
Code:
FROM_UNIXTIME(datetime2,'%d/%m/%y %T')
is blank, could anyone please help me with modify the statement please?


Code:
SELECT names, phone, returntrip, cprice, prepay, selpassengers, selinfantseats, selchildseats, selboosterseats, selluggage, selcarry, PickupAddr1, PickupAddr4, FROM_UNIXTIME(datetime1,'%d/%m/%y %T'), FROM_UNIXTIME(datetime2,'%d/%m/%y %T'), message, begin, end, state, payment, vehicletype, driver_id FROM #__taxibooking_orders WHERE driver_id = {$UserId}

Thanks in advance
 
If that's a custom function I'd do it there, but

ISNULL(ThatFunction, 0)
 
Hi

Sorry it isn't a function, it is just a query from a web application to a mysql database?

Thanks
 
So did you try ISNULL?
 
Yes I did try but it didn't work, fields were returned as blank regardless of whether they contained a value. The code that i posted returned 01/01/70 01:00:00 if they were blank so someone on stackloverflow kindly posted a response of

Code:
IF(FROM_UNIXTIME(datetime2,'%Y') = '1970', NULL, FROM_UNIXTIME(datetime2, '%d/%m/%y %T'))

which worked perfectly :)
 

Users who are viewing this thread

Back
Top Bottom