How to get only date from the complete date?

Hello,

I need to get only date from the whole date
09/12/2022

If date is 09/12/2022 then bot should take 9.
If date is 12/12/2022 then bot should take 12.

I tried to format it but its giving with zero

Now.ToString(“dd”)

Now.ToString(“d”) and this is not working.

Is there a way to get this date?

Hi @harshikakhatri269

Please use Now.Day

cheers

Hi @harshikakhatri269

How about this expression?

DateTime.ParseExact("09/12/2022","dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture).Day

image

Regards
Gokul

Hi,

Can you try the following?

Now.ToString("%d")

image

Regards,

Hello @harshikakhatri269
You can either use Modify Date activity as below or the expression provided below.

DateTime.ParseExact(strVar, "MM/dd/yyyy", Globalization.CultureInfo.InvariantCulture).ToString("dd")

image

Hello @harshikakhatri269
Try this

Your Expression is Good, Just Add space before “d”
Now.Tostring(" d").trim
image

DateTime.ParseExact("12/12/2022","dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString(" d").Trim
image

date retrieval was mentioned. Is it tried from a string or DateTime.

Unfortunately, your culture / local info is not shared. e.g. European 09/12 could be the 9th December

What was done, and what is the exact not working

have a look on a few samples


with a visual surprise of:
grafik

Handled as mentioned above:

@Anil_G thanks, it’s working

1 Like

@Gokul001 its working too.
Thanks for the reply

@Gokul_Jayakumar yes, with space it worked.

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