How to get week from specified date range

hello,

i have start date and end date mentioned in excel i need to get week for that same week.
cehck below ss

here output is - week 5
so i need week number for above dates
how can i get that?
help m eon same

@Mathkar_kunal,

May be try this approach.

Get week number for start and end date individual and then check if it’s the same or not. If same take that as week number else that would be going to be exception may be.

weekNumber = DatePart(DateInterval.WeekOfYear, DateTime.ParseExact("2025-01-26", "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture), FirstDayOfWeek.Monday, FirstWeekOfYear.System)

it is week 5

but showung in outpt as 4

why?

@Mathkar_kunal,

Is your system calendar week start from Sunday?

Because 26 Jan is on Sunday hence it’s falling under week 4.

@Mathkar_kunal,

Check this one

weekNumber = DatePart(DateInterval.WeekOfYear, DateTime.ParseExact("2025-01-26", "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture), FirstDayOfWeek.Sunday, FirstWeekOfYear.System)

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