Check the current date is in between two given dates

Check the current date is in between two given dates

  
I get the date from the user and store it in to the DateToRide Entity Attribute. And I do have to check the attribute is between two dates for example if the RideDate is 12-31-2015 , I need to check if 12-31-2015 comes between 12-26-2015 and 01-08-2016. so I use below code
NewRider.DateToRide >#2015-12-26# and NewRider.DateToRide < #2016-01-08#
If the given date is between 12-26-2015 and 01-08-2016 I set the other attribute PayPeriod to 1. Anf if the between 01-09-2015 and 01-22-2016 I set the other attribute PayPeriod to 2. Like this I have for 26 Pay periods. How can I achieve this, do I have to use 26 if condition or is there any other approach.Help is greatly appreciated.
Hi v,

Are your dates going to be change or will you be having static dates forever?
When I've done this type of thing in the past I created a static entity that has, at a minimum, the following attributes.

PayYear - four digit integer
PayWeek - two digit integer
PayStartDate - starting date
PayEndDate - ending date

You would then create static records starting with the oldest period you need and going at least a year into the future.  It is certainly possible to calculate all this on the fly using the various date functions but I have found that approach to be extremely time consuming from a testing standpoint, trying to verify every edge condition for years going forward.  Doing it this way it will always work.  Once your static records are created you just need an aggregate with two filters of:

DateToRide >= PayStartDate
DateToRide <= PayEndDate

Create another aggregate exactly the same but use CurrDate() (or some other fixed date) instead of DateToRide.  That will return the current year and week number.  You can then test the year and week number returned by the DateToRide aggregate and do whatever you want.

Hope this helps,
Curt
Suraj Borade wrote:
Hi v,

Are your dates going to be change or will you be having static dates forever?
 
 Suraj,

It keeps changing every year. For the year 2016 I have the pay periods  definied already which I am using now. It looks complicated to have 26 if condition and I am not sure if  this is the correct way to do.

Curt Raddatz wrote:
When I've done this type of thing in the past I created a static entity that has, at a minimum, the following attributes.

PayYear - four digit integer
PayWeek - two digit integer
PayStartDate - starting date
PayEndDate - ending date

You would then create static records starting with the oldest period you need and going at least a year into the future.  It is certainly possible to calculate all this on the fly using the various date functions but I have found that approach to be extremely time consuming from a testing standpoint, trying to verify every edge condition for years going forward.  Doing it this way it will always work.  Once your static records are created you just need an aggregate with two filters of:

DateToRide >= PayStartDate
DateToRide <= PayEndDate

Create another aggregate exactly the same but use CurrDate() (or some other fixed date) instead of DateToRide.  That will return the current year and week number.  You can then test the year and week number returned by the DateToRide aggregate and do whatever you want.

Hope this helps,
Curt
 
 Thanks Curt. I am little confused. Do you have any sample for me to look at it. Thanks
I have attached a simple OML file that demonstrates this.  Note that I only put in dates for the first 12 weeks of 2016.

Hope this helps,
Curt
Thank you Curt  I am not abe to open the .oml because we are currently using 9.0.0.19 and we  haven't upgraded it.

Is there any way to open the .oml
Not that I am aware of, sorry.  And I do not have access to any version other than 9.1.  If you are really desparate I can try and describe what I did with screen shots.

Curt
It would be really great to have the screen shoots. Thanks a ton.
Thank you so much Curt I was able to open in my other computer which the version of the sample. It was reallly helpful. ThaNKS