Hi
In a date i want to add no of weeks .
Thanks
Hi
In a date i want to add no of weeks .
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Ali BenchaabanRank #925 · 2.2K reputationPosted Mar 29, 2023, 3:51 AM EDT
Hello Ramco,
You can use DATEADD() function to add weeks to DateTime in Sql Server. DATEADD() functions first parameter value can be week or wk or ww, all will return the same result.
SELECT GETDATE() 'Today',DATEADD(week,2,GETDATE()) 'Today + 2 Weeks' SELECT GETDATE() 'Today',DATEADD(wk,2,GETDATE()) 'Today + 2 weeks' SELECT GETDATE() 'Today',DATEADD(ww,2,GETDATE()) 'Today + 2 Weeks'*
BENCHAABAN Ali
Sachin SinghRank #66 · 26.2K reputationPosted Mar 29, 2023, 4:19 AM EDT
for sql
DATEADD(week,2,CONVERT(datetime, yourDate))Naimish MakwanaRank #324 · 7.7K reputationPosted Mar 29, 2023, 6:43 AM EDT
Hello Ramco,
Use this.
DateTime date = DateTime.Now; // Replace with your desired date int numWeeks = 4; // Replace with the number of weeks you want to add DateTime newDate = date.AddDays(numWeeks * 7); // Add the number of days equivalent to the number of weeksThanks
Naimish Makwana
Rajkiran SwainRank #165 · 14.4K reputationPosted Mar 29, 2023, 4:11 PM EDT
// Create a new date object
let date = new Date();
// Add 4 weeks (28 days) to the date object
date.setDate(date.getDate() + 28);
// Output the new date
console.log(date);
Ramco RamcoRank #462 · 5.4K reputationPosted Mar 30, 2023, 8:58 AM EDT
Hi Naimish
In below code i want to add 2 weeks to vsessiondate
foreach (var colum in Result) { DateTime? vSessionDate = null; Session Rec = bALSessionc.GetDetail(colum.Session); vSessionDate = Rec.SessionDate; }Thanks
Anandu G NathRank #681 · 3.5K reputationPosted Dec 27, 2023, 3:50 AM EST
SELECT GETDATE() 'Today-',DATEADD(week,2,GETDATE()) 'Today + 2 Weeks' SELECT GETDATE() 'Today-',DATEADD(MM,2,GETDATE()) 'Today + 2 month' SELECT GETDATE() 'Today-',DATEADD(YY,2,GETDATE()) 'Today + 2 Year'