18
Views
10
Comments
Solved
Get Number of days per month for a specified date range
Question

I have two dates From date and To date, from which I want to show number of days per month coming in this date range. 

For ex. FromDate: 26 Apr 21 ToDate: 30 jun 21

Result should be

April  May  June

5         31     30


Any help would be really appreciated!! 

mvp_badge
MVP
Solution

Hi Shweta,

In addition to the previous comments, I want to suggest a low code solution for the mentioned use case. 

See this sample app CalculateDaysTask

Refer to the attached .oml file.


I hope this helps you!


Kind regards,

Benjith Sam

RWALabGetDaysCount.oml

Nice solution @Benjith Sam !!

I will save it here in my favorites :D

Hey @Benjith Sam,

Nicely done, please note, choosing 6/1 to 7/1 returns no days for July.

For e.g. 6/1 to 7/2 does report 2 days for July :

Regards,

AJ

mvp_badge
MVP

Hi, @Marcio Carvalho & @AJ.  Thank you for the feedback :)

@AJ. Sorry! I'm not able to understand the case you stated. Without any code change, this is how the current logic worked for me.

Date range: 06/01 to 07/01

Date range: 06/01 to 07/02

Note that the Date value captured in To/From input widget is in dd/mm/yyyy Date format


Kind regards,

Benjith Sam

I am located in the USA, and when I access your link, the calendar follows mm/dd/yyyy format automatically.

Try selecting in your format (dd/mm/yyyy) from 1/6/2021 to 1/7/2021 and see if July goes missing in the ouput and that would replicate the issue. If not then I guess it works well for dd/mm/yyyy format!

Regards,

AJ

Hi ,

Selecting the first day of any month in To Date is not getting calculated as the if condition is ToDate >  TempDate. Need to change this if condition to  ToDate >=  TempDate so that the first day of month is calculated.

Regards,

Harika

Thank you for @Harika Ramadalai! that's it. Hope that helps the original poster @Shweta Gedam.

Regards,

AJ

mvp_badge
MVP

Thank you, @Harika Ramadalai & @AJ., for helping me with the correction :)

As mentioned, I have updated the IF condition with ToDate >= TempDate expression value and its working as required :)


Kind regards,

Benjith Sam

Hello there, have you tried this?

In the end you must sum all the values in the column cal_date

regards,

Márcio C.

What you need to do, is get the month of the first date and the day and subtract for the number of days for that month. Then you go on loop and sum the number of days for each month, and on the last month, you get the day and subtract to the number of days for that month and sum to the last days summed.

This is my theoretical way to do

Regards,

Márcio

mvp_badge
MVP
Solution

Hi Shweta,

In addition to the previous comments, I want to suggest a low code solution for the mentioned use case. 

See this sample app CalculateDaysTask

Refer to the attached .oml file.


I hope this helps you!


Kind regards,

Benjith Sam

RWALabGetDaysCount.oml

Nice solution @Benjith Sam !!

I will save it here in my favorites :D

Hey @Benjith Sam,

Nicely done, please note, choosing 6/1 to 7/1 returns no days for July.

For e.g. 6/1 to 7/2 does report 2 days for July :

Regards,

AJ

mvp_badge
MVP

Hi, @Marcio Carvalho & @AJ.  Thank you for the feedback :)

@AJ. Sorry! I'm not able to understand the case you stated. Without any code change, this is how the current logic worked for me.

Date range: 06/01 to 07/01

Date range: 06/01 to 07/02

Note that the Date value captured in To/From input widget is in dd/mm/yyyy Date format


Kind regards,

Benjith Sam

I am located in the USA, and when I access your link, the calendar follows mm/dd/yyyy format automatically.

Try selecting in your format (dd/mm/yyyy) from 1/6/2021 to 1/7/2021 and see if July goes missing in the ouput and that would replicate the issue. If not then I guess it works well for dd/mm/yyyy format!

Regards,

AJ

Hi ,

Selecting the first day of any month in To Date is not getting calculated as the if condition is ToDate >  TempDate. Need to change this if condition to  ToDate >=  TempDate so that the first day of month is calculated.

Regards,

Harika

Thank you for @Harika Ramadalai! that's it. Hope that helps the original poster @Shweta Gedam.

Regards,

AJ

mvp_badge
MVP

Thank you, @Harika Ramadalai & @AJ., for helping me with the correction :)

As mentioned, I have updated the IF condition with ToDate >= TempDate expression value and its working as required :)


Kind regards,

Benjith Sam

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.