WeekDay Problem

  • Hi all, hope you can help me with this little problem I have.

    I have created a web page which has two date fields on it, I am currently using the current date in the first date field, but would like to make the second show 20 working days from the first.

    E.g

    Date 1 (11/04/2005) Monday 'UK DATE'

    Date 2 should then show (09/05/2005) Monday adding 20 days to the first.

    Is this possible?

    I have already looked through the forum and have not found anything that would help.

    Cheers

  • So if I understand you correctly you want

    select getdate() as today

    select dateadd(d, 20, getdate()) as [20daystime]

    although if you want it to be 20 working days I'll leave the logic up to you

  • There was a good posting on "Work Days" a while back. 

    I grabbed this from it: 

    DECLARE @StartDate datetime,

     @EndDate datetime

    SELECT @StartDate = '01/01/2005'

    SELECT @EndDate = GETDATE()

    SELECT (DATEDIFF( dd, @StartDate, @EndDate) + 1)

      - ( DATEDIFF( wk, @StartDate, @EndDate) * 2)

      - ( CASE WHEN DATENAME( dw, @StartDate) = 'Sunday' THEN 1 ELSE 0 END)

      - ( CASE WHEN DATENAME( dw, @EndDate) = 'Saturday' THEN 1 ELSE 0 END)

     

    I apologize for not remembering who actually wrote this to give them credit. 

    I wasn't born stupid - I had to study.

  • Thanks very much to both of you.

    Much appreciated.

    Cheers

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

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