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

  • Home
  • SEARCH
  • 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 149689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:10:13+00:00 2026-05-11T09:10:13+00:00

I have a reporting services (SQL 2008) report with two Date/Time parameters – begindate

  • 0

I have a reporting services (SQL 2008) report with two Date/Time parameters – begindate and enddate. I need to constrain enddate to the same month and year as begindate. This seems like it should be an easy thing to do, but I cannot figure it out.

Currently, I am checking the parameters passed to the stored procedure and raising an error if the two datetime parameters are not in the same month and year. I am looking for a more elegant way of accomplishing this.

  • 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. 2026-05-11T09:10:14+00:00Added an answer on May 11, 2026 at 9:10 am

    You can check the EndDate value in parameter expression, and if it’s incorrect, set it to StartDate + 1 Month.
    Something like:

    = IIF(DateDiff(DateInterval.Month, Parameters!StartDate.Value, Parameters!EndDate.Value) = 0, Parameters!EndDate.Value, AddDate(DateInterval.Month, 1, Parameters!StartDate.Value)) 

    If you just want notify user, you can place some hidden text box with appropriate formatting (red big font) and message about date parameters incorrect range. In Hidden expression set

    = (DateDiff(DateInterval.Month, Parameters!StartDate.Value, Parameters!EndDate.Value) <> 0) 

    Also, you can combine both actions with custom code:

    Public DateMessage As String  Public Function ValidateDate(StartDate As DateTime, EndDate As DateTime) As DateTime   Dim ResultDate As DateTime   If (DateDiff(DateInterval.Month, StartDate, EndDate) <> 0) Then     ResultDate = AddDate(DateInterval.Month, 1, StartDate)     DateMessage = String.Format('End Date parameter value {0}        was out of range and was changed to {1}', EndDate, ResultDate)   Else     ResultDate = EndDate   End If End Function 

    Then, in Parameter value expression:

    = Code.ValidateDate(Parameters!StartDate.Value, Parameters!EndDate.Value) 

    In Value property of tbDateParameterMessage textbox:

    = Code.DateMessage 

    And in Hidden property expression:

    = String.IsNullOrEmpty(Code.DateMessage) 

    EDIT But if you want to stop report running, use this custom code:

    Public Function CheckDate(SDate as Date, EDate as Date) as Integer     Dim msg as String     msg = ''     If (SDate > EDate)  Then         msg='Start Date should not be later than End Date'     End If     If msg <> '' Then         MsgBox(msg, 16, 'Parameter Validation Error')         Err.Raise(6,Report) 'Raise an overflow     End If End Function 

    It’s taken from SQLServerCentral forum.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Looks like you're rendering your text directly to the recycle… May 11, 2026 at 8:04 pm
  • Editorial Team
    Editorial Team added an answer You call regasm with the /codebase parameter: > regasm.exe /codebase… May 11, 2026 at 8:04 pm
  • Editorial Team
    Editorial Team added an answer I think your first questions are a matter of taste.… May 11, 2026 at 8:04 pm

Related Questions

I have a reporting services (SQL 2008) report with two Date/Time parameters - begindate
I've just installed Microsoft SQL Server Express 2008 (with Reporting Services). My installation is
I have a reporting services project with lots of reports developed in SQL server
I am using SQL Server Reporting Services 2008 (though this seems to be an
Report design, generation and maintenance isn't hard, but it is dull. We have a

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.