USING VB 6.0
How to select previous row value?
Am Selecting a Date between fromdate and todate using date picker
Code
Dim stdate, endate as string
stdate = Fromdate
endate = todate
Example:
fromdate: 01-01-2009
todate: 01-06-2009
Data’s will display fromdate to todate.
I want to select previous date means previous row value. How to select previous row value?
We cannot give
stdate = - fromdate
endate = - todate
It will display a data’s between 31-01-2008 to 31-05-2009
We cannot give
Stdate = <fromdate
endate = < todate
It will display a data’s before 01-01-2009 and also we cannot use > in between condition
Stdate = fromdate (Here how can I give “from previous row value of the fromdate”)
endate = todate (here how can I give “to previous row value of the todate”)
Example:
id, date, name
01, 02-01-2009, raja
01, 04-01-2009, raja
02, 04-01-2009, ravi
so on.....
01, 28-05-2009, raja
01, 31-05-2009, raja
so on...
am selecting a date stdate = 04-01-2009, endate= 31-05-2009
Output shoud display like this -
01, 02-01-2009, raja
01, 04-01-2009, raja
02, 04-01-2009, ravi
.......
01, 28-05-2009, raja
It should dipslay one record Before ssdate and endate.
How to select previous row value?
Need Help in VB 6 code.
-
I do not completely understand what you are doing, but if you have a recordset object that is sorted on date you need to need something like
If (recordset.BOF = False) Then recordset.MovePrevious End If
If you are asking how to get a recordset that contains one record before the start date you are going to have to expand your query to try to include at least on record before the fromdate, find the first record with the fromdate, then use the MovePrevious method above.
If you are just asking how to get a date prior to a given date then use the DateAdd method.
example - the below code will subtract 1 day from 2/1/2009 and put 1/31/2009 into the valriable.
dtPreviousDate = DateAdd("D", CDate("02-01-2009"), -1)
From Beaner
0 comments:
Post a Comment