Working with date fields in data can be a challenge and one of those challenges is why you have this subject today. One of our customers asked me if we could restrict some Dynamics CRM data by only pulling records for the current year. I think a few other people may want to do something similar so here are the steps for doing this. (I used the Opportunity Entity but it will work for any Dynamics CRM date field)


1) Create a Global Variable called GBL_CURRENTYEAR


globalvariable



2) Create a Pre-Map Task to run a script and use the following to pull the current year: GBL_CURRENTYEAR = Date.Today.Year


script
3) Now we can edit the CRM Query to include the Criteria for the current year in what ever Date field you choose like below:

>=’GBL_CURRENTYEAR-01-01′ AND <=’GBL_CURRENTYEAR-12-31′


query-criteria
This will assist you in creating a restriction on any Dynamics CRM date field.


Thanks,

Chris