Getting day of date as single digit number?

Right now I have DateTime.Now.AddDays(-22).ToString("dd") to test it out.

For example instead of 06 I want 6.

The “-22” is to test how it looks with single digit numbers and it’s showing as double digit number (as of writing this, it is showing 06 instead of 6).

I only need the day of the date too. I am using this to find the row where I will insert my data into an excel. I’ve tried looking around, no luck so far :frowning:

Hi,

Can you try the following expression?

DateTime.Now.AddDays(-22).ToString("%d")

Regards,

1 Like

It works, thank you! What does the % do if I may ask?

Hi,

It’s specification.
Please see the following document - Section : Using single custom format specifiers, in detail.

Regards,

1 Like

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