Discussion on:
View:
Show:
This didn't work for me - it had a problem with "timespan" and gave the error "type expected". The code just wouldn't run, even though timespan seemed to be an option, ie it was in the automatic list that pops up.
Moira, the problem is that you cannot declare the TimeSpan as given in the code. I encountered the same problem as you did(i.e. the "type expected" error msg).
This works fine for me...
Dim tsTimeSpan As New System.TimeSpan
If you change to the above declaration, it should work.
All the best
This works fine for me...
Dim tsTimeSpan As New System.TimeSpan
If you change to the above declaration, it should work.
All the best
I tried what you suggested and though it appeared to accept the code, ie no zig zag underlining of words occurred, running it produced the message that there were build errors and when I chose to continue anyway it said something about not finding timespan.exe.
As usual for many of these .NET tips, the technique illustrated has a VB6 equivalent function "baked in".
if t1 and t2 are strings containing valid date expressions, then this...
td = DateDiff("d", t1, t2)
...returns the difference in days between t1 and t2.
It's days because the first parameter is "d". You can have years, months, hours, minutes, or whatever interval size you want. See the VB6 help for DateDiff() to see valid values.
For example...
td = DateDiff("d", "1/1/2007", "2007 March 23")
...returns 81 (which is correct). Note that about any recognizable date format will do.
Couldn't really be any easier.
Chuck Somerville
Dayton Ohio
if t1 and t2 are strings containing valid date expressions, then this...
td = DateDiff("d", t1, t2)
...returns the difference in days between t1 and t2.
It's days because the first parameter is "d". You can have years, months, hours, minutes, or whatever interval size you want. See the VB6 help for DateDiff() to see valid values.
For example...
td = DateDiff("d", "1/1/2007", "2007 March 23")
...returns 81 (which is correct). Note that about any recognizable date format will do.
Couldn't really be any easier.
Chuck Somerville
Dayton Ohio
- Keyboard Shortcuts:
- Prev
- Next
- Toggle

































