Question: I have a table with 4 columns value , animal\_id, food\_id and timestamp. Time stamp records the data in unix time. Currently my script is working fine and produces a table like this. This is all great and all but this forces me to go edit the file and change the timestamp each day for today's midnight timestamp and this is quite time consuming. Is there a way to produce this line of code for every day without having to update it ? Thank you in advance. I use oracle 10g.

The line in the script I want to change

WHERE timestamp BETWEEN 1406073600 AND (1406073600 + 86400)

The Script

```
SELECT MAX(value),animal_id, food_id 
FROM farm1 
WHERE timestamp BETWEEN 1406073600 AND (1406073600 + 86400)
group by animal_id, food_id ;

```

The Table Results

```
MAX(VALUE)  animal_id    food_id
---------- ---------- ----------
      9302          8       9081
      8015         10       9081

```

Answer: 
Unfortunately I don't have enough rep to comment, otherwise I wouldn't post this as an answer. Really, I need a little more information. Are you doing this as an expression within the report builder or as part of your dataset?

If its part of your dataset then I suggest using a `case` statement.

```
case
when TotalAfterMarkup.Value >0
then SUM(Fields!Total.Value -  
   Fields!TotalAfterMarkup.Value) /       
  (Fields!TotalAfterMarkup.Value) 
else '0.00%'
end [MyFieldName]

```

Using an IIF Statement: ("Dataset = Your Dataset Name")

```
=IIF(Fields!TotalAfterMarkup.Value, "CostTable") >0, SUM(Fields!TotalCost.Value,   "CostTable") - (Fields!TotalAfterMarkup.Value, "CostTable") / (Fields!TotalAfterMarkup.Value, "CostTable"), "0.00%")

```
I think this should work:

```
=IIF(TotalAfterMarkup.Value > 0,(SUM(Fields!Total.Value -  
Fields!TotalAfterMarkup.Value)/(Fields!TotalAfterMarkup.Value)),0)

```

The IIF function is the one you use for evaluating conditions in SSRS:

[Expression Examples (Report Builder and SSRS) - See decision function section](http://msdn.microsoft.com/en-us/library/ms157328.aspx)