January 9, 2008 at 6:46 am
I gave you the code example that demonstrates how to determine if it was correctly entered to the nearest tenth of an hour... heh... didn't intend to write your whole app 😉 You can't take it from here?
--Jeff Moden
Change is inevitable... Change for the better is not.
January 9, 2008 at 6:56 am
If you're trying to do validation - you should try the conversion without doing the division. In order to be valid, according to the numbers you're putting out only numbers that are divisible by 36,000 are valid.
so - use something like
where t%36000=0
for any valid entries. Any nonzero values out of that are invalid according to your new rule.
Again - prevent the entry up front. It's much better than tryng to clean up later.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
January 9, 2008 at 7:03 am
thanks matt, it works
may i know what is that % doing there
January 9, 2008 at 7:09 am
% is the modulo operator. Modulo means to return the integer remainder of a division.
so 72%36=0 (since 72 divides evenly by 36)
73%36=1
74%36=2, etc...
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
January 9, 2008 at 7:18 am
And obviously you'd use a check constraint on the table rather than something ugly like a trigger with a rollback inside it 🙂
January 9, 2008 at 7:22 am
thank you very much matt. Appreciate your help
January 10, 2008 at 3:45 am
select cast(cast(1.1 as decimal(19,1)) / cast(5.0 as decimal(19,1)) as decimal(19,1))
Obviously you can change the 1 into different numbers to add decimals. Also the cast of the numbers is not necessary in this case.. just to show you how it works
[edit] sorry didnt see more pages than one... so you already have the solution[/edit]
Viewing 7 posts - 16 through 21 (of 21 total)
You must be logged in to reply to this topic. Login to reply