Hi,

My application is in VS2008 coded in vb.net.I have a table with three columns

FromDate,Todate and Schedule.FromDate and ToDate will have date values whereas Schedule will have a any of these values(weekly,Monthly,Yearly)

In my Form i have given some provision to the user to check the records.My requirement is The currentdate that is Today's date should be compared with the values of Fromdate and ToDate.First it should be check whether Schedule value is Weekly or Monthly or Yearly.If it is weekly than it should check the record in between fromDate to ToDate with a increment of one week.That means it should first check the first value of fromDate than add 7 days to the value and then again check from fromDate and this should continue till it reaches Todate.

Im trying something like this but its not giving me good logic.

If Schedule = "Weekly" Then
 While Today >= FromDate And Today<= ToDate
 If Today = fromDate Then
  My application Code here
  End If
  fromDate.AddDays(7)
  End While
  End If

I dont think its making any sense.

Please Guide at the earliest.

Hi Siddiq

Sort with the day format ... For example if the user requires sheduled detail of say Date X which falls in say wednesday.... Now pick out the wednesdays from your fromdate and todate and compare with the dateX ... if u are using date data type it will be simple.... Also try using the .Net's calendar tool


Rgrds

Sam

hi Zed,
Thnks for the reply
the thing is user will not get the day to look for.It will all happen in the background after the record from Database is retrieved.So we will not be certain about a particular day.We have two dates and need to play with them along with the Schedule filter.It its weekly the record should be checked for every fromdate + 7 kinda logic.
I hope this would clear what im exactly trying to get.
Thanks again.

You've said database, which makes me wonder what happens when today = fromdate.
Are you be going back to the database and checking for something? What db are you using?

Edited 5 Years Ago by adam_k: n/a

Hi adam,
what i posted was actually a sample code a bit similar to my application.I cant post my actual code due to company policies.I just wanted the logic,im done with my issue.
Thanks for the reply.

hi! i just dealt with a similar situation! this is how I solved it, using your example
NB' fromDate I assumed is declared as a date

dim fromDate as date = fromDate
If Schedule = "Weekly" Then
While Today >= FromDate And Today<= ToDate
If Today = fromDate Then
' My application Code here
End If
fromDate = format(DateAdd(DateInterval.Day,7,fromDate),"dd-mm-yyyy")
End While
End If

This article has been dead for over six months. Start a new discussion instead.