expression for date and time

0
Hello everyone,    I’m beginner in Mendix. I want to write a microflow by taking two variables as Start_Date & End_Date of type date & time. I got stuck in taking financial year as 1st October of current year as my start date and 30th September of next year as end date dynamically at runtime. Can someone suggest me Xpath expression for the respective one.   for example case 1 if start date = 1st October 2022 then end date should be 30th September 2023 then FY = 2022-2023 it should detect date dynamically at runtime. 
asked
2 answers
1

Hi Shubham,

For this, create a variable StartDate and set the value as “parseDateTimeUTC('01/10/2022','dd/MM/yyyy')” and create another variable of datetime as “EndDate” and set the value as “parseDateTimeUTC('30/09/2023','dd/MM/yyyy')”. Then you can add a decision and check if the current date lies between both, change the financial year to “2022-2023”, else if greater than end date change it to “2023-2024” else change it to “2021-2022”. Hope this helps!

 

 

 

answered
1

Hi Shubham,

Please see below -

  • Create a variable StartDate and set the value as "parseDateTimeUTC('01/10/'+formatDateTimeUTC([%CurrentDateTime%],'yyyy'),'dd/MM/yyyy')"
  • Create another variable EndDate and set the value as "parseDateTimeUTC('30/09/'+formatDateTimeUTC(addYearsUTC([%CurrentDateTime%],1),'yyyy'),'dd/MM/yyyy')”
  • Add a descision to check if the current date is below start date, set the financial year as "formatDateTimeUTC(addYearsUTC([%CurrentDateTime%],-1),'yyyy')+'-'+formatDateTimeUTC([%CurrentDateTime%],'yyyy')"
  • Else check if current date is beyond end date, set the financial year as "formatDateTimeUTC([%CurrentDateTime%],'yyyy')+'-'+formatDateTimeUTC(addYearsUTC([%CurrentDateTime%],1),'yyyy')"
  • Else, set the value of financial year as "formatDateTimeUTC($StartDate,'yyyy')+'-'+formatDateTimeUTC($EndDate,'yyyy')".

I hope this will help!

 

 

answered