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. Number Of Days

Number Of Days

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelpquestion
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.
  • F Offline
    F Offline
    FireOnMoon
    wrote on last edited by
    #1

    how can i calculate the number of days in the current month in MS SQL Server 2000. can any body help me, no matter wether usage of Stored Proc, or any other code, i am sick of working on it. FIRE

    F 1 Reply Last reply
    0
    • F FireOnMoon

      how can i calculate the number of days in the current month in MS SQL Server 2000. can any body help me, no matter wether usage of Stored Proc, or any other code, i am sick of working on it. FIRE

      F Offline
      F Offline
      Frank Kerrigan
      wrote on last edited by
      #2

      This will do it. DECLARE @MonthInt int DECLARE @YearInt int DECLARE @TempVarChar varchar(30) DECLARE @Mth_Start datetime DECLARE @Mth_End datetime DECLARE @DaysInMonth int SET @MonthInt = 08 SET @YearInt = 2005 -- GET START NEXT MONTH START IN Char Set @TempVarChar = '01/' + CAST(@MonthInt As Varchar(2) ) + '/' + CAST(@YearInt As Varchar(4) ) -- Convert to Date Set @Mth_Start = (Convert( datetime, @TempVarChar, 103 )) -- Go Back one day to get last day in Month. Set @Mth_End = DATEADD( dd, -1, @Mth_Start) -- Get total days in Month SET @DaysInMonth = DATEPART(dd, @Mth_end) SELECT @DaysInMonth

      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