Subtract date

3 posts, 1 answers
  1. Felice
    Felice avatar
    198 posts
    Member since:
    Aug 2013

    Posted 08 Jan 2014 Link to this post

    I need to subtract two date from dateTimeColumns.

    I tried in the designer:
    DATEDIFFDAY(Periodo, Data_Pagam), in the designer

    I tried with the code:

     radGridView1.Columns["Ritardo"].Expression = "Periodo-Data_Pagam";


    I keep getting this error:
    Invalid Expression:
    "Cannot perform '-' operation on System.DateTime and System.DateTime

    Please help.
  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    2949 posts

    Posted 08 Jan 2014 Link to this post

    Hello Felice,

    Thank you for writing.

    You should specify the appropriate parameters directly when you are initializing the expression:
    radGridView1.Columns["Duration"].Expression = "DATEDIFFDAY(StartTime ,EndTime)";

    Also I have attached a sample project that contains a sample implementation for such functionality.

    I hope this will be useful. Should you have further questions, I would be glad to help.

    Regards,
    Dimitar
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. Felice
    Felice avatar
    198 posts
    Member since:
    Aug 2013

    Posted 09 Jan 2014 Link to this post

    Thank you, you solved my problem.
Back to Top