none
How do I subtract 30 minutes from a time in a reportreview control textbox? RRS feed

  • Question

  • Hello,
     
    I have a textbox with the following code in the expression on my report design:

    (CDate(First(Fields!clsStartTime.Value)).Hour).Subtract(30).TotalMinutes  
     
     

    When I run my code, the value for clsStartTime is say 8. What I want to accomplish is that whatever value clsStartTime holds, to subtract it by 30 minutes. Therefore 8 would read 7:30.

    This is the error that the above code returns:

    Error 3 The Value expression for the textbox ‘textbox14’ contains an error: [BC30456] 'Subtract' is not a member of 'Integer'. 

    How can I make this work?

    Thanks in advance.
    Monday, October 20, 2008 7:16 PM

Answers

  • The hour property just returns an Integer 8, which doesn't have a Subract method. That's why you are getting an exception.

    Try:
    =CDate(First(Fields!clsStartTime.Value)).AddMinutes(-30).ToShortTimeString()

    This would return 7:30AM given a date time with a time component of 8:00AM.
    Nick Allen, Microsoft SQL Server Reporting Services. This posting is provided "AS IS" with no warranties and confers no rights.
    • Marked as answer by Rashar Tuesday, October 21, 2008 12:48 PM
    Monday, October 20, 2008 11:16 PM

All replies

  • The hour property just returns an Integer 8, which doesn't have a Subract method. That's why you are getting an exception.

    Try:
    =CDate(First(Fields!clsStartTime.Value)).AddMinutes(-30).ToShortTimeString()

    This would return 7:30AM given a date time with a time component of 8:00AM.
    Nick Allen, Microsoft SQL Server Reporting Services. This posting is provided "AS IS" with no warranties and confers no rights.
    • Marked as answer by Rashar Tuesday, October 21, 2008 12:48 PM
    Monday, October 20, 2008 11:16 PM
  • Perfect! Thanks for your help.
    Tuesday, October 21, 2008 12:49 PM