#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    104
    Rep Power
    5

    Take the first day of the month and the last day of the month ?


    Get the first day of the month and the last day of the month ?

    Below is the error code

    // Get the first day of the month
    kptDTPickerTo.Format = DateTimePickerFormat.Short;
    kptDTPickerTo.Value = "01/" + DateTime.Today.Month + "/" + DateTime.Today.Year;//New Date(iYear, iMonth, 1);

    // Get last day of the month
    kptDTPickerFrom.Value = DateTimePickerFormat.Short;
    kptDTPickerFrom.Value = "01/" + DateTime.Today.AddMonths(1) + "/" + DateTime.Today.Year;
    kptDTPickerFrom.Value = kptDTPickerFrom.Value - 1;
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,413
    Rep Power
    1871
    And what is the error?

    Does it compile? If not, what are the error messages?
    Does it run and crash?
    Does it run, but always gives erroneous answers?
    Does it run, but occasionally gives erroneous answers?

    What does it do!?


    > // Get last day of the month
    > kptDTPickerFrom.Value = DateTimePickerFormat.Short;
    Surely you mean .Format =
    Which you have in the first example.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    187
    Rep Power
    83
    Maybe this link can provide a solution to your problem.

IMN logo majestic logo threadwatch logo seochat tools logo