Hi

In my VB program, I am going through a database, adding each row/record to a listview. One of these fields is a date. For each row/record, I want to get the difference in days between that date, and the corresponding date in the next row/record.

Thanks
Robert

Hi,

You could use the DateDiff command.

Syntax:
DateDiff(interval,date1,date2)

e.g.
DaysLeft = DateDiff("d",Now,"25/12/2005")
MonthsLeft = DateDiff("m",Now,"25/12/2005")


pG

Hi

Thanks for the quick reply. However, the tricky bit is how to get the difference between dates where the dates are in different records from an SQL SELECT. I'm going through a "Do Until .GotLastRow()" loop, and imagine that in each iteration, I can somehow get the next row, use the date and do the datedif with the first date, then move back to the previous row. Is this possible, or is there some other method?

Thanks
Robert

ADO allows you to use the MoveNext / MovePrevious methods on a recordset allowing you to move back and forth as much as you like.

Thanks for your answer Mark. I would like to do what you suggest, but I am missing something here. My object doesn't have MoveNext etc in it's list of methods. Do I have to open the database with a different method, or class. How to I get the results of my SQL SELECT appear as a RecordSet ?

Thanks
Robert

HOw are you opening your recordset? ADO or RDO?

Hi Mark

My open is...
Set objDB = New clsDataSource
objDB.OpenIt (strFile)
The class looks like..
clsDataSource(ADODataSource.cls)

Is that enough to tell you what I am doing wrong?

Thanks Mark

Robert

No. Someone has written a wrapper for some of the ADO stuff by the look of things. What methods are available?

Hi Mark

Here are the methods I get from the drop-down list

CloseIt
ColumnExists
DateDelim
GetColumnAttributes
GetColumnCount
GetColumnName
GetColumnSize
GetColumnType
GetColumnValue
GetNextRow
GotLastRow
LastError
OpenIt
PerformSQL
SetColumnValue
SQL
ValueOfFalse
ValueOfTrue
WriteToLogFile

Thanks
Robert

GetNextRow looks like it does something. Is there a 'GetPreviousRow' or something? If there isn't it would be pretty trivial to add this to the class. Just copy the GetNextRow code, change the procedure name, and change the method used to 'MovePrevious' instead of MoveNext. There'll probably be a check for EOF that you'll need to change to BOF too.

hi
In my VB program, when we select a day from a calendar and it should show what the day and month it will be after 90 days from the current date.... hope you al can guide me to complete my promblem.. waiting 4 your reply...

Thank you..

use the dateadd function


Good Luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.