|
-
Apr 22nd, 2004, 02:15 PM
#1
Thread Starter
New Member
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
-
Apr 22nd, 2004, 04:25 PM
#2
Hyperactive Member
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)
-
Apr 22nd, 2004, 08:01 PM
#3
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|