Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 670835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:18:27+00:00 2026-05-14T00:18:27+00:00

Using MS SQL Server .I have made a Stored Procedure named SP_Get_CallsLogged . I

  • 0

Using MS SQL Server.I have made a Stored Procedure named SP_Get_CallsLogged.

I have a table named TRN_Call, and it has one column named CallTime which is a DateTime.

I have a web-page in my application where the User enters:-

  1. StartDate (DateTime)

  2. EndDate (DateTime)

  3. Period (Daily/Weekly/Monthly) (varchar) (from DropDownList)

I want to get the Record Count of those calls in my table TRN_Call on the basis of the specified Period(Daily/Weekly/Monthly) selected by user in the DropDownList.

e.g.

StartDate ='1/18/2010 11:10:46 AM'
EndDate   ='1/25/2010 01:10:46 AM'
Period    =Daily

So the record count between these above mentioned dates(StartDate+EndDate) should come in a manner so that I can refer to those counts separately i.e. the following:-

Date 1/18/2010 Records Found 5
Date 1/19/2010 Records Found 50
Date 1/20/2010 Records Found 15
Date 1/21/2010 Records Found 32
Date 1/22/2010 Records Found 12
Date 1/23/2010 Records Found 15
Date 1/24/2010 Records Found 17
Date 1/25/2010 Records Found 32

and send those counts to the Web Application so that these counts could be listed then in the Crystal Reports.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:18:27+00:00Added an answer on May 14, 2026 at 12:18 am

    I would edit your stored procedure to pass the start date and end date selected in your web page so that you can include them in the WHERE clause.

    -- Daily
    SELECT CallTime, COUNT(*) AS 'Records Found'
    FROM TRN_Call
    WHERE CallTime BETWEEN @StartDate AND @EndDate
    GROUP BY CallTime
    

    Weekly can be quite complex.

    If you check this link you will see a function (below) which you can use to help you get the weekly results

    e.g. So create the function below

    create function FiscalWeek (@startMonth varchar(2), @myDate datetime)  
    returns int  
    as  
    begin  
    declare @firstWeek datetime  
    declare @weekNum int  
    declare @year int  
    set @year = datepart(year, @myDate)+1  
    --Get 4th day of month of next year, this will always be in week 1  
    set @firstWeek = convert(datetime, str(@year)+@startMonth+'04', 102)  
    --Retreat to beginning of week  
    set @firstWeek = dateadd(day, (1-datepart(dw, @firstWeek)), @firstWeek)  
    while @myDate < @firstWeek --Repeat the above steps but for previous year  
     begin  
      set @year = @year - 1  
      set @firstWeek = convert(datetime, str(@year)+@startMonth+'04', 102)  
      set @firstWeek = dateadd(day, (1-datepart(dw, @firstWeek)), @firstWeek)  
     end  
    set @weekNum = (@year*100)+((datediff(day, @firstweek, @myDate)/7)+1)  
    return @weekNum  
    end  
    

    Now, you should be able to run the code below which should group up by weeks. To choose between if you want Day, Week or Year you will also have to pass period selected by the user to your stored procedure.

    (ps. Havent got round to doing year yet)

    SELECT dbo.FiscalWeek('04', CallTime), dbo.FiscalWeek('04', CallTime)%100 ,  COUNT(*) AS 'Records Found - Weekly'
    FROM TRN_Call
    WHERE CallTime BETWEEN @StartDate AND @EndDate
    GROUP BY dbo.FiscalWeek('04', CallTime), dbo.FiscalWeek('04', CallTime)%100  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 378k
  • Answers 378k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer With respect of CreateObject("InternetExplorer.Application") you create an instance of Internet… May 14, 2026 at 9:12 pm
  • Editorial Team
    Editorial Team added an answer You can use a pagination class for that. May 14, 2026 at 9:12 pm
  • Editorial Team
    Editorial Team added an answer you can determine the next sunday using PHP then pass… May 14, 2026 at 9:12 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.