Question: I'm trying to add a text switcher dynamically but I get the error:

> 
> The method setFactory(ViewSwitcher.ViewFactory) in the type ViewSwitcher is not applicable for the arguments...
> 
> 
> 

Here's my code:

```
TextSwitcher ts = (TextSwitcher) new TextSwitcher(this);
ts.setFactory(this);
Animation in = AnimationUtils.loadAnimation(this,android.R.anim.fade_in);
Animation out = AnimationUtils.loadAnimation(this,android.R.anim.fade_out);
ts.setInAnimation(in);
ts.setOutAnimation(out);

```

Answer: 
```
SELECT TIMEDIFF( MAX(time_col), MIN(time_col) ) FROM [tablename];

```

This will be helpful when it stores in time-sequentially. But timestamp column can be modified by updating, so I suggest the below query than above one.

```
SELECT TIMEDIFF( x.time_col, y.timecol ) FROM 
    ( SELECT time_col FROM [tablename] ORDER BY [primary_key] DESC LIMIT 1 ) x,
    ( SELECT time_col FROM [tablename] ORDER BY [primary_key] ASC  LIMIT 1 ) y

```

---

You can use TIMESTAMPDIFF function either.

```
SELECT TIMESTAMPDIFF( SECOND, x.time_col, y.timecol ) FROM 
    ( SELECT time_col FROM [tablename] ORDER BY [primary_key] DESC LIMIT 1 ) x,
    ( SELECT time_col FROM [tablename] ORDER BY [primary_key] ASC  LIMIT 1 ) y

```
this example is using mysql\_\* function in php,  

you can replace to whatever method you are comfortable with

```
$con = mysql_connect(...); // your connection
$sql = <<<SQL
select 
  max(the_field) as last_time ,
  min(the_field) as first_time,
  timestampdiff(second, min(the_field), max(the_field)) as diff_time
from your_table
SQL;
$res = mysql_query($sql, $con);
$row = mysql_fetch_assoc($res);
mysql_free_result($res);

```