time

  • 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


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • 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?

  • thanks matt, it works

    may i know what is that % doing there

  • % 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?

  • And obviously you'd use a check constraint on the table rather than something ugly like a trigger with a rollback inside it 🙂

  • thank you very much matt. Appreciate your help

  • 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