Date.AddWeeks Function in Power Query
The Date.AddWeeks function returns a Date/DateTime/DateTimeZone value incremented by the number of weeks provided. Each week is defined as a duration of seven days. It also handles incrementing the month and year potions of the value as appropriate.
Syntax
Date.AddWeeks(dateTime as any, numberOfWeeks as number) as any
Example:
Power Query M
let Source = Table.FromRecords( { [Name = "Ashish", Year = "20-07-2024"], [Name = "Katrina", Year = "21-07-2024"], [Name = "John", Year = "22-07-2024"], [Name = "Salman", Year = "23-07-2024"], [Name = "Akshay", Year = "24-07-2024"], [Name = "Shahrukh", Year = "25-07-2024"], [Name = "Alia", Year = "26-07-2024"], [Name = "Karishma", Year = "27-07-2024"], [Name = "Anjali", Year = "28-07-2024"], [Name = "Jenelia", Year = "29-07-2024"], [Name = "Esha", Year = "30-07-2024"], [Name = "Kareena", Year = "31-07-2024"], [Name = "Aishwariya", Year = "01-08-2024"], [Name = "Pallavi", Year = "02-08-2024"], [Name = "Jatin", Year = "03-08-2024"], [Name = "Joseph", Year = "04-08-2024"], [Name = "Hemant", Year = "05-08-2024"], [Name = "Deepti", Year = "06-08-2024"] } ), // Convert the "Year" column from text to date format Converted = Table.TransformColumnTypes(Source, {{"Year", type date}}), // Modify the "Year" column directly by adding 1 year to each date return = Table.TransformColumns(Converted, {{"Year", each Date.AddWeeks(_, 1), type date}}) in return
The output will be shown in the following image: