Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Round to next 5 value
Message
De
07/03/2007 12:23:33
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01201576
Message ID:
01201617
Vues:
14
Hi Kirk,

One way is the following T-SQL code. You could take the relevant code that does the work and put it into a function. Change the value of @x to test the code.
declare @M int, @X int
select @x = 35

--	This code does the work
select @M = @x % 5
if ( @M > 2 )
	select @x = @x + 5 - @m
else
	select @x = @x - @m

--	Display the value
select @X
>I have a value that represents duration, some of them are like 29, 14, 59. In my case these represent minutes, I'm looking for a way within a stored procedure to "round" them to the nearest 5 minute value.
>
>so 29 would become 30
>.. 14 would become 15
>.. 59 would become 60
>
>Thanks for any help.
>
>Kirk
William A. Caton III
Software Engineer
MAXIMUS
Atlanta, Ga.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform