Results 1 to 6 of 6

Thread: [RESOLVED] Date + Date

  1. #1

    Thread Starter
    Addicted Member scsfdev's Avatar
    Join Date
    Feb 2008
    Location
    Singapore
    Posts
    224

    Resolved [RESOLVED] Date + Date

    Hi all,

    Merry Christmas to you all.

    I have a question
    Let's say I have a count like 20 Days or 1 Week or 2 Months.

    I like to add these value to Today Date.

    without chopping, checking and adding the value is there any way I can do it ?

    Because now my user may choose 20 or 10 days, or 1 week or 2 weeks, or 3 months or 1 month. (even years!!)

    And I need to add this value to Today. (This is a processing for Getting Expiry Date)

    I'm kind of stuck here.

    The only way I can think of is chopping out Date or Month or Year and plus the user key-in value to this. And re-calculate the value and display it on screen.

    Its kind of messy.
    So, any idea??

    Thanks.
    scsfdev

    -----------------------------------------------
    Merry Christmas and Happy New Year to you all.
    I'm using VS 2005 & 2008 & 2010 with SQL Server 2005 Express.

    My hobby beside programming: http://dslrstranger.wordpress.com

  2. #2
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,051

    Re: Date + Date

    Check out the DateAndTime class.

    DateAndTime.DateAdd method

  3. #3
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,051

    Re: Date + Date

    Wrong class

    Check out the DateTime class

    Look for the Add methods.

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

    Re: Date + Date

    Quote Originally Posted by FourBlades View Post
    Wrong class

    Check out the DateTime class

    Look for the Add methods.
    DateTime is a structure, not a class. Doesn't really make much difference to the way it's used in many cases, including this case, but it's important to know whether you're dealing with reference types or value types much of the time.
    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
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Date + Date

    Some code info here.
    http://msdn.microsoft.com/en-us/libr....datetime.aspx

    Code:
            Dim dtF As New DateTime
            dtF = DateTime.Now.AddMonths(1)
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  6. #6

    Thread Starter
    Addicted Member scsfdev's Avatar
    Join Date
    Feb 2008
    Location
    Singapore
    Posts
    224

    Re: Date + Date

    Hi all,

    thanks for all ur suggestions. It solved my problems.

    I feel more and more of lack behind in .Net environment

    According to this example, i don't even know such easy things. I feel ashamed of my ability. I still need more to learn.
    I'm using VS 2005 & 2008 & 2010 with SQL Server 2005 Express.

    My hobby beside programming: http://dslrstranger.wordpress.com

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