Why I am getting date format like this 21/0/2022?

Hello Everyone,
I am using System.DateTime.Today.AddDays(-1).ToString(“d/m/yyyy”)
command but I am getting month as zero every time. Can anyone suggest to me what changes I should make in the above syntax so I can get the correct Date?

Hi,

Can you try as the following?

System.DateTime.Today.AddDays(-1).ToString("d/M/yyyy")

note: m means minute, M means month.

Regards,

Hey!

Try this…

Now.AddDays(-1).ToString("d/M/yyyy")

Regards,
NaNi

you can try like this instead of that

System.DateTime.Today.AddDays(-1).ToString(“dd/MM/yyyy”)

Hello Veera_Raj,
The issue is not resolved yet still facing the same problem even after changing to dd/mm/yyyy.

Thank You for Instant Reply

Hello THIRU_NANI,
I tried what you suggested but got output like this 21/17/2022.

can you tell me format of output you expecting ?

mm should be upper case

FYI

It’s working fine

Regards,
NaNi

Hey!

should be “M”

The “m” - Minute
The “M” - Month

Regards,
NaNi

Thank You, Yoichi,
Your suggestion worked for me. Got the correct result.
Thank You

Yes. Got the mistake that I committed.

1 Like

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