Results 1 to 3 of 3

Thread: Subtracting Between Dates...

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    13

    Subtracting Between Dates...

    Hello all,

    I am desperately trying to get a program working, but cannot get it to subtract between two dates using the DateTimePicker tool. It is a Uni assignment. The user has to enter two dates, one is subtracted from the other and then the user clicks on a button to Calculate. The code in question is as follows:

    Dim Calc_CurrentDateText As String
    Dim Calc_DateJoinedText As String
    Calc_CurrentDateText = Calc_CurrentDatePicker.Value.Date
    Calc_DateJoinedText = Calc_DateJoinedPicker.Value.Date

    ReckonableService = Calc_CurrentDateText - Calc_DateJoinedText

    I have tried setting the 'Dim Calc_CurrentDateText as String' to Date, Double, etc, but nothing seems to work.

    Any help would be appreciated.

    Thanks in advance.

    Adrian

  2. #2
    Hyperactive Member scuzymoto's Avatar
    Join Date
    Aug 1999
    Location
    Washington State
    Posts
    316
    Use the datediff function, it does all the work for you...

    here is a sample right from microsoft...

    Code:
    DateDiff(DateInterval.Day, CDate("01/01/2003"),Cdate("01/01/2004") )
    The results of the line above would be 365.

    You could also do it like this...

    Code:
    DateDiff(DateInterval.Month, CDate("01/01/2003"),Cdate("01/01/2004") )
    The result this time would be 12, (12 months difference in the dates)
    SCUZ

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    13

    Talking

    Thanks so much for your help, it works a treat

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