Microsoft SQL 2005 - using the modulo operator
- by cc0
So I have a silly problem, I have not used much MSSQL before, or any SQL for that matter. I basically have a minor mathematical problem that I need solved, and I thought modulo would be good.
I have a number of dates in the database, but I need them be rounded off to the closest [dynamic integer] (could be anything from 0 to 5000000) which will be input as a parameter each time this query is called.
So I thought I'd use modulo to find the remainder, then subtract that remainder from the date.
If there is a better way, or an integrated function, please let me know!
What would be the syntax for that? I've tried a lot of things, but I keep getting error messages like integers/floats/decimals can't be used with the modulo operators. I tried casting to all kinds of numeric datatypes.
Any help would be appreciated.