Results 1 to 8 of 8

Thread: [RESOLVED] Reset DateTime Control

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    426

    Resolved [RESOLVED] Reset DateTime Control

    How can i reset my datetime control to display a date that is three months back instead of the current date.
    Thanks in advance.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Reset DateTime Control

    The Value property of a DateTimePicker is a DateTime object, so that's the property you should be getting or setting if you want to make changes in code, e.g.
    VB Code:
    1. myDateTimePicker.Value = Date.Today.AddMonths(-3)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    426

    Re: Reset DateTime Control

    Thanks, that will give me the same day 3 months back. What if i want the 1st day of the month, three months back!!

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Reset DateTime Control

    Think laterally!! You have the date three months ago and you want the date of the first day of that month. You can't set the Day of that specific Date object because it is ReadOnly, so you would create a new Date object with the same Year and Month but a Day of 1.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    426

    Re: Reset DateTime Control

    Yap, my own function. Thanks.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    426

    Re: Reset DateTime Control

    The problem i have, is that my datetime control is on a split container, when i toggle the container panel where it is, to false, it doesnt allow it, or rather changes it to date today. How can i pass over this!!

    It works perfect when i put it in free space on the form and set the value of the control in the form load event.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] Reset DateTime Control

    Huh?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    426

    Re: [RESOLVED] Reset DateTime Control

    True....!! test it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width