Dates in string format

Can you help to get following values in string format?

Only last sunday date (-7 days from today) from today - Format “dd”
Only the year (-7 days from today) - Format “yyyy”
Only the month ( - 7 days from today) - Format “MMMM”

@Sathish_Kumar_S

Now.Adddays(-7).ToString("dd")

Now.Adddays(-7).year

Now.Adddays(-7).ToString("MMMM")

Is this what you need?

or sunday Now.AddDays(Cint(Now.DayOfWeek)*-1).ToString("dd")

cheers

Hi @Sathish_Kumar_S

How about this Date expression?

DateTime.Now.AddDays(-7).Year.ToString()

DateTime.Now.AddDays(-7 - (7 + CInt(DateTime.Now.DayOfWeek)) Mod 7).ToString("dd")

DateTime.Now.AddDays(-7).Month.ToString() / DateTime.Now.AddDays(-7).ToString("MMMM")

image

image

Regards
Gokul