Start date and month is not getting updated properly

Hi All

month and date is not getting updated properly

image
image

the Out put is shwoing wrong for start date
image

Hi @Sam_H ,

From the Screenshots provided, we could observe that there are two Type Into Activities for the Start Date.

Could you provide us the Expression used for both of the activities ?

You could also check by Debugging at that Type Into Activity and Computing in the Immediate Panel, each piece value present in the Type Into activity. It should give you the idea as to what is the source of the error.

@supermanPunch

Start Date : value.tostring+ā€œ16ā€+Date.Mow.ToShortDateString.Split{ā€œ/ā€},StringSplitOptions.None).Trim

End Date : New DateTime(Now.Year,Now.Month 1).adddays(-1).toshortdatestring

Facing the issue in Start date

i Have to select Date 16th to 31th last month here

Hey @Sam_H ,

Better if you can explain your issue what exactly you want in the start and end date.

You are not doing the datetime manipulation properly, you are writing some complex logic to add or subtract the values from the datetime, better if you could go through this Custom date and time format strings | Microsoft Learn it will help you out to clear the datetime concept.

Thanks,
Sanjit

@Sanjit_Pal

I have to select the date 16th Jan to 31th Jan of last month

issue i’m facing is in start date 0 is not getting added for month

@Sam_H ,

From your recent statement made above, we can understand that you would want to Type the value as 16th Jan, as you would want to get Jan 16th, the Logic could be summed as you would want - Previous Month 16th Date as Start Date and Previous Month Last Date as End Date

If the above logical Statement is true for your requirement, then we could use the below Expression :
For End Date :

(new DateTime(Now.AddMonths(-1).Year,Now.AddMonths(-1).Month,DateTime.DaysInMonth(Now.AddMonths(-1).Year,Now.AddMonths(-1).Month))).ToString("MM/dd/yyyy")

For Start Date :

(new DateTime(Now.AddMonths(-1).Year,Now.AddMonths(-1).Month,16).ToString("MM/dd/yyyy")

If the above Logical explanation is not what was required. You could let us know in more detail as to what is the date required to be used.

We still do not know why there is a Split function used and What does the value variable contain.

1 Like

@Sam_H

StartDateLastMonth = New DateTime(today.Year, today.Month, 16).AddMonths(-1)
EndDateLastMonth = New DateTime(today.Year, today.Month, 1).AddDays(-1)
image

Thanks,
Sanjit

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.