Possible ways to get the day before the 26 weeks of the current day?
I wish to get the date before the 26 weeks of the current day via C#.
Any one provide me suggestions on the way to get the day?
c# datetime
add a comment |
I wish to get the date before the 26 weeks of the current day via C#.
Any one provide me suggestions on the way to get the day?
c# datetime
add a comment |
I wish to get the date before the 26 weeks of the current day via C#.
Any one provide me suggestions on the way to get the day?
c# datetime
I wish to get the date before the 26 weeks of the current day via C#.
Any one provide me suggestions on the way to get the day?
c# datetime
c# datetime
edited Nov 12 at 12:44
Soner Gönül
79.7k26147271
79.7k26147271
asked Nov 12 at 12:40
Mahendra Prabhu
2,1171536
2,1171536
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
If I understand you correctly, you could try this:
Since 26 weeks is 26 x 7 days, you can use AddDays
on any given DateTime
object.
var result = DateTime.Now.AddDays(-26 * 7);
Console.WriteLine(result);
Console.WriteLine(result.DayOfWeek);
Output:
5/14/2018 12:44:36 PM
Monday
See msdn, and note:
The value parameter can be negative or positive.
add a comment |
Assuming you mean literally 26 weeks of seven days each, you can do it like this:
DateTime.Today.AddDays(-7 * 26)
Thank u for your response. Worked +!
– Mahendra Prabhu
Nov 13 at 4:39
add a comment |
var result = DateTime.Now.AddDays(-26 * 7);
var result2 = DateTime.Now.Add(new TimeSpan(-26 * 7, 0, 0, 0));
var result3 = DateTime.Now.AddHours(-26 * 7 * 24);
var result4 = DateTime.Now.Subtract(new TimeSpan(26 * 7, 0, 0, 0));
var result5 = DateTime.Now.Subtract(new TimeSpan(0, 26 * 7 * 24, 0, 0));
And so one.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53262411%2fpossible-ways-to-get-the-day-before-the-26-weeks-of-the-current-day%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
If I understand you correctly, you could try this:
Since 26 weeks is 26 x 7 days, you can use AddDays
on any given DateTime
object.
var result = DateTime.Now.AddDays(-26 * 7);
Console.WriteLine(result);
Console.WriteLine(result.DayOfWeek);
Output:
5/14/2018 12:44:36 PM
Monday
See msdn, and note:
The value parameter can be negative or positive.
add a comment |
If I understand you correctly, you could try this:
Since 26 weeks is 26 x 7 days, you can use AddDays
on any given DateTime
object.
var result = DateTime.Now.AddDays(-26 * 7);
Console.WriteLine(result);
Console.WriteLine(result.DayOfWeek);
Output:
5/14/2018 12:44:36 PM
Monday
See msdn, and note:
The value parameter can be negative or positive.
add a comment |
If I understand you correctly, you could try this:
Since 26 weeks is 26 x 7 days, you can use AddDays
on any given DateTime
object.
var result = DateTime.Now.AddDays(-26 * 7);
Console.WriteLine(result);
Console.WriteLine(result.DayOfWeek);
Output:
5/14/2018 12:44:36 PM
Monday
See msdn, and note:
The value parameter can be negative or positive.
If I understand you correctly, you could try this:
Since 26 weeks is 26 x 7 days, you can use AddDays
on any given DateTime
object.
var result = DateTime.Now.AddDays(-26 * 7);
Console.WriteLine(result);
Console.WriteLine(result.DayOfWeek);
Output:
5/14/2018 12:44:36 PM
Monday
See msdn, and note:
The value parameter can be negative or positive.
edited Nov 12 at 12:58
answered Nov 12 at 12:42
Stefan
8,17873760
8,17873760
add a comment |
add a comment |
Assuming you mean literally 26 weeks of seven days each, you can do it like this:
DateTime.Today.AddDays(-7 * 26)
Thank u for your response. Worked +!
– Mahendra Prabhu
Nov 13 at 4:39
add a comment |
Assuming you mean literally 26 weeks of seven days each, you can do it like this:
DateTime.Today.AddDays(-7 * 26)
Thank u for your response. Worked +!
– Mahendra Prabhu
Nov 13 at 4:39
add a comment |
Assuming you mean literally 26 weeks of seven days each, you can do it like this:
DateTime.Today.AddDays(-7 * 26)
Assuming you mean literally 26 weeks of seven days each, you can do it like this:
DateTime.Today.AddDays(-7 * 26)
answered Nov 12 at 12:42
stuartd
49.8k1096123
49.8k1096123
Thank u for your response. Worked +!
– Mahendra Prabhu
Nov 13 at 4:39
add a comment |
Thank u for your response. Worked +!
– Mahendra Prabhu
Nov 13 at 4:39
Thank u for your response. Worked +!
– Mahendra Prabhu
Nov 13 at 4:39
Thank u for your response. Worked +!
– Mahendra Prabhu
Nov 13 at 4:39
add a comment |
var result = DateTime.Now.AddDays(-26 * 7);
var result2 = DateTime.Now.Add(new TimeSpan(-26 * 7, 0, 0, 0));
var result3 = DateTime.Now.AddHours(-26 * 7 * 24);
var result4 = DateTime.Now.Subtract(new TimeSpan(26 * 7, 0, 0, 0));
var result5 = DateTime.Now.Subtract(new TimeSpan(0, 26 * 7 * 24, 0, 0));
And so one.
add a comment |
var result = DateTime.Now.AddDays(-26 * 7);
var result2 = DateTime.Now.Add(new TimeSpan(-26 * 7, 0, 0, 0));
var result3 = DateTime.Now.AddHours(-26 * 7 * 24);
var result4 = DateTime.Now.Subtract(new TimeSpan(26 * 7, 0, 0, 0));
var result5 = DateTime.Now.Subtract(new TimeSpan(0, 26 * 7 * 24, 0, 0));
And so one.
add a comment |
var result = DateTime.Now.AddDays(-26 * 7);
var result2 = DateTime.Now.Add(new TimeSpan(-26 * 7, 0, 0, 0));
var result3 = DateTime.Now.AddHours(-26 * 7 * 24);
var result4 = DateTime.Now.Subtract(new TimeSpan(26 * 7, 0, 0, 0));
var result5 = DateTime.Now.Subtract(new TimeSpan(0, 26 * 7 * 24, 0, 0));
And so one.
var result = DateTime.Now.AddDays(-26 * 7);
var result2 = DateTime.Now.Add(new TimeSpan(-26 * 7, 0, 0, 0));
var result3 = DateTime.Now.AddHours(-26 * 7 * 24);
var result4 = DateTime.Now.Subtract(new TimeSpan(26 * 7, 0, 0, 0));
var result5 = DateTime.Now.Subtract(new TimeSpan(0, 26 * 7 * 24, 0, 0));
And so one.
answered Nov 12 at 13:00
Nekeniehl
553420
553420
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53262411%2fpossible-ways-to-get-the-day-before-the-26-weeks-of-the-current-day%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown