The last 15th

Hi All!

Does anyone now a good way to type/determine the last 15th date(dd-MM-yyyy)

So if the current date is the 8th of may, the output is the 15th of april. And if the current date is the 28th of june, the output is the 15th of june.

Hope i makes sense!

1 Like

you can get by
Now.Adddays(-15).ToString

Hi @ChrisPals,

You can do it in a simple way,

Here are the steps :

  1. Check today’s date using : Now.Date
  2. Check whether the date is above 15 or below …
  3. If above 15, then date you need to enter is 15- Now.Month - Now.Year
  4. Else the date will be 15 -( Now.Month - 1) - Now.Year
4 Likes

get the current day and month now.Day and now.month if its is grater than 15 then check if condition if it is true construct the date as 15 june if it is less than then 15 of current month -1 i.e may

Fine to get the 15 th date of a month
we can go like this buddy (sorry for the previous comment) @ChrisPals
lets say you are giving input like this with a datetime variable

  1. in_datetime_string = “28/04/2019”
  2. in_datetime_date = Convert.ToInt32(Datetime.ParseExact(in_datetime_string,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd”))

which will give us output like this
in_datetime_date = 28
where in_datetime_date is a variable of type int32

  1. out_value of type int32
    out_value = in_datetime_date - 15
    out_value = 28 - 15
    out_value = 13

  2. now final value we need is
    out_final of type int32
    out_final = in_datetime_date - (out_value)
    out_final = 28 - 13
    out_final = 15 (we got the date now)

  3. so now we need to get as a date
    like this with a assign activity
    in_datetime_string = in_datetime_string.ToString.Replace(in_datetime_date.ToString,out_final.ToString)

in_datetime_date = Convert.ToInt32(Datetime.ParseExact(in_datetime_string,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd”))

now finally the date will be 15/04/2019

Cheers @ChrisPals

Hi All

The issue is now solved by using @HareeshMR proposed method.

Thank you @HareeshMR and thank you all for your quick responses to the topic.

4 Likes

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