Required week number from current date

Hi,

I need a week number from current date,

I have used below code but am getting “3” if run it for todays date but I need “03”,

System.Globalization.CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(System.DateTime.Now, System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.CalendarWeekRule,System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek)

Regards,
Saurav

@SauravYadav
A quick read through the docs suggests neither the Calendar.GetWeekOfYear or the DateTime.ToString functions have this functionality. What you could do is use an If statement to check if the number is less than 10 and if it is add a “0” to the front when you use it.

@SauravYadav

have a look on the PadLeft function e.g. .toString.PadLeft(2, “0”)

1 Like

you can use that dude, this help me.

Hi All,

Rather to find week number expression, I have used IF condition to check the week number as shown below and it works.

image

Regards,
Saurav

1 Like

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