tags:

views:

158

answers:

2

I store the long values in mssql using bigint so I could do something like this:

--@start and @end are bigint
set @duration = @start - @end

now I need some additional operation so I could get the duration in seconds, anybody knows how ?

+1  A: 

I guess it really depends on what those values were .. you say Java long, so it makes me wonder if you're doing something like System.currentTimeMillis() and then shoving that value in the database. If that's the case, then just dividing the duration by 1,000 would get you seconds.

More information in the question would be helpful.

BryanD
yes this is what I do, System.currentTimeMilis
Omu
+1  A: 
import java.util.concurrent.TimeUnit;

...
/* "seconds" is the number of seconds sinced the epoch began. */
long seconds = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
erickson
I need that in sql ;)
Omu
of course I could send seconds to sql and not bother with storing long values in sql, probably that's also a good idea, who knows
Omu