It is currently Mon May 21, 2012 1:23 pm

All times are UTC + 2 hours [ DST ]




Post new topic Reply to topic  [ 13 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Problem in Case Statement
PostPosted: Fri Nov 11, 2011 7:59 am 
Offline

Joined: Wed Oct 26, 2011 4:41 am
Posts: 41
Until now, I did not solve my problem, I don't know how can i used use union..


Top
 Profile  
 
 Post subject: Re: Problem in Case Statement
PostPosted: Mon Nov 14, 2011 12:19 pm 
Offline

Joined: Wed Oct 26, 2011 4:41 am
Posts: 41
Good day!

My boss told me that I no need to add field for shift, but I got a problem in my code for the shift 21:35-05:35 and also in 13:35-21:35 .
here is the code:

[code]
$result = mysql_query("UPDATE attendance SET Rendered = sec_to_time(time_to_sec('08:00:00') +
case
when time_to_sec(time(TimeIn)) < time_to_sec('21:35:00') then 0
else time_to_sec('21:35:00') - time_to_sec(time(TimeIn))
end +
case
when time_to_sec(time(TimeOut)) > time_to_sec('05:35:00') then 0
else time_to_sec(time(TimeOut)) - time_to_sec('05:35:00')
end
)")
or die(mysql_error());

$result = mysql_query("UPDATE attendance SET Rendered = sec_to_time(time_to_sec('08:00:00') +
case
when time_to_sec(time(TimeIn)) < time_to_sec('13:35:00') then 0
else time_to_sec('13:35:00') - time_to_sec(time(TimeIn))
end +
case
when time_to_sec(time(TimeOut)) > time_to_sec('21:35:00') then 0
else time_to_sec(time(TimeOut)) - time_to_sec('21:35:00')
end
)")
or die(mysql_error());
[/code]

i have time in : 2011-10-24 21:35:00 time out: 2011-10-25 08:35:00
and the ouput in rendered using this code is: -14:00:00 it should be 08:00:00

timein : 2011-10-24 13:35:00 timeout: 2011-10-24 21:35:00 rendered: 02:25:00 it should be 08:00:00

Help me...Thank you so much


Top
 Profile  
 
 Post subject: Re: Problem in Case Statement
PostPosted: Tue Nov 15, 2011 7:28 pm 
Offline

Joined: Sun May 02, 2004 11:34 pm
Posts: 6535
Location: toronto, canada
try reversing the subtraction statements

case
when time_to_sec(time(TimeOut)) > time_to_sec('05:35:00') then 0
else time_to_sec('05:35:00') - time_to_sec(time(TimeOut))
end

_________________
Lostboy

Cat, the other other white meat

Please read Posting Etiquette before posting

You can always try Google


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ]  Go to page Previous  1, 2

All times are UTC + 2 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron