Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
swift
Starting Member
4 Posts |
Posted - 2006-07-21 : 10:24:39
|
| The DATEDIFF(s, time1, time2) function output is of the 'datetime' datatype.How can I alter the 'datetime' to 'int' (or 'bigint') datatype to make it compatible with other variables in my calculations? |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-07-21 : 10:28:27
|
| Give an exampleWhat date to what integer, and if there is a logic, that as well.eg. do u need 12/04/2006 to 12042006 ?Srinika |
 |
|
|
swift
Starting Member
4 Posts |
Posted - 2006-07-21 : 10:52:36
|
| It is not the issue of time FORMAT.Here is an example. I am using DATEDIFF(s, '07/20/2006 00:00:00','07/20/2006 00:05:00'),which returns 300 seconds.However I cannot calculate, for example, the incoming bitrate becausedividing 100,000 bits (bigint) by seconds (datetime) is not alloweddue to different datatypes. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-07-21 : 10:56:22
|
datediff does not return datetime datatype but rather integer.what is your problem with dividing 100000 by the seconds ? KH |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-07-21 : 11:01:03
|
| Datediff returns integereg. Print DATEDIFF(s, '07/20/2006 00:00:00','07/20/2006 00:05:00') / 100returns 3Srinika |
 |
|
|
swift
Starting Member
4 Posts |
Posted - 2006-07-21 : 11:17:22
|
| DECLARE @TimeDif AS bigint............SET @TimeDif = DATEDIFF (s, @TimePrev, @TimeCurr)SET @InBitRate = (@InBitCurr - @InBitPrev)/@TimeDif'Msg 8134, Level 16, State 1, Line 182Divide by zero error encountered.' |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-07-21 : 11:21:16
|
| ie because ur @TimeDif = 0 in that instancenothing to do with date data type or some such.U may commentout the row where the dividing is taking place and put the Print TimeDif and c.The values of @TimePrev & @TimeCurr should be same, thus making the difference in seconds to become 0.Srinika |
 |
|
|
swift
Starting Member
4 Posts |
Posted - 2006-07-21 : 11:34:42
|
| You are right -I goofed with calculation of @TimePrev. Thanks, everybody. |
 |
|
|
|
|
|
|
|