Datetime compare with specific time

  • Hi i need to calculate the TAT in my application. i am having date like this :

    InTime OutTime

    12/17/2012 8:40:00 PM 12/18/2012 7:40:00 AM

    If Intime is <= 9 PM (then the TAT need to <=8 AM EST for the following business day) - MET OR NOT MET

    12/17/2012 9:40:00 PM 12/18/20129:40:00 AM

    If Intime is >= 9 PM (then the TAT need to <=9 PM EST for the second business day - MET OR NOT MET

    Please Help me and give some ideas.

  • Kasinathan (2/1/2013)


    Hi i need to calculate the TAT in my application. i am having date like this :

    InTime OutTime

    12/17/2012 8:40:00 PM 12/18/2012 7:40:00 AM

    If Intime is <= 9 PM (then the TAT need to <=8 AM EST for the following business day) - MET OR NOT MET

    12/17/2012 9:40:00 PM 12/18/20129:40:00 AM

    If Intime is >= 9 PM (then the TAT need to <=9 PM EST for the second business day - MET OR NOT MET

    Please Help me and give some ideas.

    Hi it seems you are pretty new around here. Your description is entirely to vague for anybody to help much. Please take a few minutes to read the article found at the first link in my signature about best practices when posting questions.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Sean Lange

    Hi it seems you are pretty new around here. Your description is entirely to vague for anybody to help much. Please take a few minutes to read the article found at the first link in my signature about best practices when posting questions

    Not to diminish Sean Lange's comment - but your request

    Please Help me and give some ideas.

    .

    Here is an idea, NOT a solution, but an idea as you requested.

    DECLARE @In DATETIME

    DECLARE @InHr DATETIME

    DECLARE @Out DATETIME

    SET @In = '12/17/2012 9:40:00 PM'

    SET @Out = '12/18/2012 7:40:00 AM'

    SELECT DATEPART(hh,@In) AS 'Hour in',DATEPART(dd,@In)AS 'Day in',DATEPART(hh,@Out) AS 'Hour out',DATEPART(dd,@Out)AS 'Day out'

    IF DATEPART(hh,@In) > DATEPART(hh,@Out) AND (DATEPART(dd,@In) = DATEPART(dd,@Out)-1)

    PRINT 'do something'

    ELSE

    PRINT 'Do NOTHING'

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Kasinathan (2/1/2013)


    Hi i need to calculate the TAT in my application.

    Heh... I hate to ask. What's a "TAT"?

    --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)
    Intro to Tally Tables and Functions

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply