Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. retrieving 3 working days

retrieving 3 working days

Scheduled Pinned Locked Moved Database
sharepointdata-structureshelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 8664010
    wrote on last edited by
    #1

    ALTER procedure [dbo].[sp_pubhol]
    as
    begin
    declare @i int
    declare @NewDate date
    set @i = 0
    while(@i<3)
    begin
    IF DATEPART(dw, DATEADD(day,@i,CONVERT(date,GETDATE()))) = 7 OR DATEPART(dw, DATEADD(day,@i,CONVERT(date,GETDATE()))) = 1
    print 'weekend'
    else
    print 'weekday'

    select Holiday_Name from Holiday where Holiday_On = DATEADD(day,@i,CONVERT(date,GETDATE()))
    SELECT @NewDate = DATEADD(DAY,@i,CONVERT(date,GETDATE()))
    RETURN @NewDate
    select @i = @i+1
    end
    end

    my task is if today is neither weekend nor public holiday ,i have to that date, increment loop...i have retrieve all the 3 working days...can anyone help me pls if i want declare @NewDate as array[[3] ,how to declare that..pls help me

    M 1 Reply Last reply
    0
    • U User 8664010

      ALTER procedure [dbo].[sp_pubhol]
      as
      begin
      declare @i int
      declare @NewDate date
      set @i = 0
      while(@i<3)
      begin
      IF DATEPART(dw, DATEADD(day,@i,CONVERT(date,GETDATE()))) = 7 OR DATEPART(dw, DATEADD(day,@i,CONVERT(date,GETDATE()))) = 1
      print 'weekend'
      else
      print 'weekday'

      select Holiday_Name from Holiday where Holiday_On = DATEADD(day,@i,CONVERT(date,GETDATE()))
      SELECT @NewDate = DATEADD(DAY,@i,CONVERT(date,GETDATE()))
      RETURN @NewDate
      select @i = @i+1
      end
      end

      my task is if today is neither weekend nor public holiday ,i have to that date, increment loop...i have retrieve all the 3 working days...can anyone help me pls if i want declare @NewDate as array[[3] ,how to declare that..pls help me

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Use a table variable not an array.

      Declare @Tbl Table(Date datetime)
      Insert @tTbl
      Select getdate()

      So instead of buying a book and studying you are going to bring every problem to the interweb forums for answer. I predict your questions shortly be ignored and no answers will be forth coming!

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups