comparing dates in a procedure/method

LisaM

Member
Licensed User
Longtime User
Hi,
I am having trouble using the date functions and wondering if someone can help me.
Basically I want to create a procedure where someone enters a commencement date for there exercise. I store this date in the DB. I then want to retrieve this date and compare it against the days current date then set the current activity for today's dates date in a label.
So something like:
Sub SetWorkoutLabel
If DayTime.Now = (date retrieved from DB) Then
Label1.Text = "Activity1"
End If
If DateTime.Now = (date retrieved from DB, 0, 0, 1) Then
Label1.Text = "Activity2"
End If
End Sub

Obviously this is not correct code just wanted to give you an idea of what I am trying to achieve
I am using an InputDialog for the user to enter a date and storing it as a string. Do I need to format the string when retrieving it from DB or do I need to store it differently?

Any help on this would be greatly appreciated.
Thanx
 

LisaM

Member
Licensed User
Longtime User
This is the code from my settings activity I am using the easy to use database.

B4X:
Sub GetDate         'Put contents of database fields in to memory fields, the db. functions calls this name GetFields, this is the name you should use
   lblDateDis.Text   = db.Field3(0,0)
End Sub
Sub PutDate
   db.Field3(0,0) = lblDateDis.Text
End Sub

Sub btnCommenceDate_Click
   cdate.Hint = "MM/DD/YYYY"
   If cdate.Show ("Enter the date you started or will start your workout.","Commencement Date","OK","Cancel","",Null) = DialogResponse.POSITIVE Then
      lblDateDis.Text = cdate.Input
      PutDate
   End If
End Sub
this is the database code
B4X:
Dim Field3(1,2) As String
   Field3(0,0) = ""   :Field(0,1)=1   'Commence Date container

So does DateTime.Date give me today's current date does it?
basically i want to ask is today's date (09/13/2012) the same as the commencement date entered (09/13/2012) Yes! then set label.text to Activity1
But i also want to do this for the next 30 days so i will need to add days
today's date (09/14/2012) the same as the commencement date entered (09/13/2012 + 1 day) Yes! then set label.text to Activity2
I did this in an app in app inventor and wanted to apply the same concept here but im having trouble figuring out the code, plus if there is an easier or better way to do it i'd love to know :)
Thnx:D
 
Upvote 0

LisaM

Member
Licensed User
Longtime User
Great thnx will see how i go :D
 
Upvote 0
Top