Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2004
    Posts
    35

    Unanswered: Logic for adding dates

    If I use dateadd(dd,n,@fromdate), it gives me the result including the weekends, is there a way to find the target date without including weekends. Please help.

  2. #2
    Join Date
    Apr 2004
    Location
    Kansas City, MO
    Posts
    734
    There isn't a way with the dateadd function. You'll need to create a date table that excludes weekends and holidays. You can the do a count from the table BETWEEN @startdate and @enddate.
    MeanOldDBA
    derrickleggett@hotmail.com
    When life gives you a lemon, fire the DBA.

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    What logic do you want? I can think of two possibilities:

    A) If date falls on a weekend, use following Monday instead.

    and 2) "n" represents the number of non-weekend days to increment @fromdate.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  4. #4
    Join Date
    Aug 2007
    Posts
    29
    Yes, if the date falls on a weekend then we would use the following Monday. I've got the field updating OK on the plus 3 days but now I have to account for the weekends and holidays.

  5. #5
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Dude! Are you the original poster? This thread is three years old!
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  6. #6
    Join Date
    Aug 2007
    Posts
    29
    Nope sorry wrong thread.

  7. #7
    Join Date
    Aug 2007
    Posts
    29
    Wrong thread.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •