Possible ways to get the day before the 26 weeks of the current day?










-3














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?










share|improve this question




























    -3














    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?










    share|improve this question


























      -3












      -3








      -3







      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?










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      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






















          3 Answers
          3






          active

          oldest

          votes


















          3














          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.







          share|improve this answer






























            2














            Assuming you mean literally 26 weeks of seven days each, you can do it like this:



            DateTime.Today.AddDays(-7 * 26)





            share|improve this answer




















            • Thank u for your response. Worked +!
              – Mahendra Prabhu
              Nov 13 at 4:39


















            1














            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.






            share|improve this answer




















              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
              );



              );













              draft saved

              draft discarded


















              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









              3














              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.







              share|improve this answer



























                3














                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.







                share|improve this answer

























                  3












                  3








                  3






                  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.







                  share|improve this answer














                  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.








                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 12 at 12:58

























                  answered Nov 12 at 12:42









                  Stefan

                  8,17873760




                  8,17873760























                      2














                      Assuming you mean literally 26 weeks of seven days each, you can do it like this:



                      DateTime.Today.AddDays(-7 * 26)





                      share|improve this answer




















                      • Thank u for your response. Worked +!
                        – Mahendra Prabhu
                        Nov 13 at 4:39















                      2














                      Assuming you mean literally 26 weeks of seven days each, you can do it like this:



                      DateTime.Today.AddDays(-7 * 26)





                      share|improve this answer




















                      • Thank u for your response. Worked +!
                        – Mahendra Prabhu
                        Nov 13 at 4:39













                      2












                      2








                      2






                      Assuming you mean literally 26 weeks of seven days each, you can do it like this:



                      DateTime.Today.AddDays(-7 * 26)





                      share|improve this answer












                      Assuming you mean literally 26 weeks of seven days each, you can do it like this:



                      DateTime.Today.AddDays(-7 * 26)






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Nov 12 at 12:42









                      stuartd

                      49.8k1096123




                      49.8k1096123











                      • 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




                      Thank u for your response. Worked +!
                      – Mahendra Prabhu
                      Nov 13 at 4:39











                      1














                      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.






                      share|improve this answer

























                        1














                        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.






                        share|improve this answer























                          1












                          1








                          1






                          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.






                          share|improve this answer












                          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.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 12 at 13:00









                          Nekeniehl

                          553420




                          553420



























                              draft saved

                              draft discarded
















































                              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.




                              draft saved


                              draft discarded














                              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





















































                              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







                              Popular posts from this blog

                              Top Tejano songwriter Luis Silva dead of heart attack at 64

                              政党

                              天津地下鉄3号線