Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Hey kids, what day is it?

Hey kids, what day is it?

Scheduled Pinned Locked Moved The Weird and The Wonderful
question
13 Posts 9 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E esaulsberry

    Why do people do this? To make my brain hurt?

    DateTime startDate = new DateTime(
    DateTime.Now.AddDays(-1).Year,
    DateTime.Now.AddDays(-1).Month,
    DateTime.Now.AddDays(-1).Day);

    DateTime endDate = new DateTime(
    DateTime.Now.Year,
    DateTime.Now.Month,
    DateTime.Now.Day);

    OriginalGriffO Offline
    OriginalGriffO Offline
    OriginalGriff
    wrote on last edited by
    #3

    To introduce subtle bugs around midnight, that require expensive fixing and guarantee a job for life?

    Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

    1 Reply Last reply
    0
    • E esaulsberry

      Why do people do this? To make my brain hurt?

      DateTime startDate = new DateTime(
      DateTime.Now.AddDays(-1).Year,
      DateTime.Now.AddDays(-1).Month,
      DateTime.Now.AddDays(-1).Day);

      DateTime endDate = new DateTime(
      DateTime.Now.Year,
      DateTime.Now.Month,
      DateTime.Now.Day);

      B Offline
      B Offline
      BobJanova
      wrote on last edited by
      #4

      I've done something similar to the second one of those, i.e.

      DateTime now = DateTime.Now;
      DateTime midnight = new DateTime(now.Year, now.Month, now.Day);

      Am I missing an elegant way to do that?

      E 1 Reply Last reply
      0
      • B BobJanova

        I've done something similar to the second one of those, i.e.

        DateTime now = DateTime.Now;
        DateTime midnight = new DateTime(now.Year, now.Month, now.Day);

        Am I missing an elegant way to do that?

        E Offline
        E Offline
        esaulsberry
        wrote on last edited by
        #5

        DateTime endDate = DateTime.Today;

        Today is Now with the time truncated.

        B A 2 Replies Last reply
        0
        • E esaulsberry

          Why do people do this? To make my brain hurt?

          DateTime startDate = new DateTime(
          DateTime.Now.AddDays(-1).Year,
          DateTime.Now.AddDays(-1).Month,
          DateTime.Now.AddDays(-1).Day);

          DateTime endDate = new DateTime(
          DateTime.Now.Year,
          DateTime.Now.Month,
          DateTime.Now.Day);

          M Offline
          M Offline
          Member 2053006
          wrote on last edited by
          #6

          Erm, I was just logging on to report myself for this. It looks very similar :-)

          System::Drawing::Rectangle clientRectangle = System::Drawing::Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height);

          I have no defense, guilty as charged :-(

          E N 2 Replies Last reply
          0
          • M Member 2053006

            Erm, I was just logging on to report myself for this. It looks very similar :-)

            System::Drawing::Rectangle clientRectangle = System::Drawing::Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height);

            I have no defense, guilty as charged :-(

            E Offline
            E Offline
            esaulsberry
            wrote on last edited by
            #7

            It would be interesting to have a coding horrors forum that only allowed self-reported craziness.

            1 Reply Last reply
            0
            • M Member 2053006

              Erm, I was just logging on to report myself for this. It looks very similar :-)

              System::Drawing::Rectangle clientRectangle = System::Drawing::Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height);

              I have no defense, guilty as charged :-(

              N Offline
              N Offline
              Nagy Vilmos
              wrote on last edited by
              #8

              The first step to recover is admitting you have a problem.:thumbsup:


              Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

              K 1 Reply Last reply
              0
              • E esaulsberry

                DateTime endDate = DateTime.Today;

                Today is Now with the time truncated.

                B Offline
                B Offline
                BobJanova
                wrote on last edited by
                #9

                Thanks, I'll try to remember that! Not that intuitive a name, to me.

                1 Reply Last reply
                0
                • E esaulsberry

                  DateTime endDate = DateTime.Today;

                  Today is Now with the time truncated.

                  A Offline
                  A Offline
                  AspDotNetDev
                  wrote on last edited by
                  #10

                  One could also use DateTime.Now.Date;.

                  Thou mewling ill-breeding pignut!

                  1 Reply Last reply
                  0
                  • E esaulsberry

                    Why do people do this? To make my brain hurt?

                    DateTime startDate = new DateTime(
                    DateTime.Now.AddDays(-1).Year,
                    DateTime.Now.AddDays(-1).Month,
                    DateTime.Now.AddDays(-1).Day);

                    DateTime endDate = new DateTime(
                    DateTime.Now.Year,
                    DateTime.Now.Month,
                    DateTime.Now.Day);

                    E Offline
                    E Offline
                    Emmanuel Medina
                    wrote on last edited by
                    #11

                    LOL It had been some time since I checked this forum and when I saw the title of this post I thought there would be tons of Rebbeca Black references (I'm writing this as of FRIDAY, September 7th)

                    1 Reply Last reply
                    0
                    • N Nagy Vilmos

                      The first step to recover is admitting you have a problem.:thumbsup:


                      Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                      K Offline
                      K Offline
                      Kenneth Haugland
                      wrote on last edited by
                      #12

                      How would that work for people who suffer from hypochondria? ;P

                      1 Reply Last reply
                      0
                      • E esaulsberry

                        Why do people do this? To make my brain hurt?

                        DateTime startDate = new DateTime(
                        DateTime.Now.AddDays(-1).Year,
                        DateTime.Now.AddDays(-1).Month,
                        DateTime.Now.AddDays(-1).Day);

                        DateTime endDate = new DateTime(
                        DateTime.Now.Year,
                        DateTime.Now.Month,
                        DateTime.Now.Day);

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #13

                        Definitely WTF worthy. :) You have my sympathies.

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups