Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have stored three essential timestamp and time into my database table, format as follows-

mysql> select receivedtime, requesttime, sla from table;
+---------------------+---------------------+----------+
| receivedtime        | requesttime         | sla      |
+---------------------+---------------------+----------+
| 2013-05-26 22:37:04 | 2013-05-26 12:37:04 | 02:59:59 |
| 2013-05-26 14:36:44 | 2013-05-21 12:39:09 | 72:00:00 |
+---------------------+---------------------+----------+
2 rows in set (0.00 sec)

I need to put few condition like below

difference = (receivedtime - requesttime);

CSS
if [difference <= sla]
{
   show meet
} else {
   show don't meet
}


legend:
receivedtime [timestamp] as because days
requesttime [timestamp] as because days
sla [time] as because hour

Need Help !
Posted
Comments
Jignesh Khant 28-May-13 5:24am    
If u want time difference try this:

TimeSpan ts = DateTime.Parse(end) - DateTime.Parse(start);

1 solution

Warning - I can't get to my MySQL instance at the moment so you may not be able to just copy&paste this ...

Try selecting from your database like this ...
select TIMESTAMPDIFF(SECOND, receivedtime, requesttime) as difference, TIME_TO_SEC(sla) as slasecs from table

and then you can do your
CSS
if [difference <= sla]
{
   show meet
} 
else 
{
   show don't meet
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900