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. General Programming
  3. C#
  4. working with datetime

working with datetime

Scheduled Pinned Locked Moved C#
question
4 Posts 4 Posters 0 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.
  • Q Offline
    Q Offline
    quiteSmart
    wrote on last edited by
    #1

    Hi all, how can i get the last day of a given month. thanks.

    C C 2 Replies Last reply
    0
    • Q quiteSmart

      Hi all, how can i get the last day of a given month. thanks.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      DateTime.DaysInMonth

      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

      1 Reply Last reply
      0
      • Q quiteSmart

        Hi all, how can i get the last day of a given month. thanks.

        C Offline
        C Offline
        cppShooter
        wrote on last edited by
        #3

        a solution: int year = DateTime.Now.Year; DateTime dt = DateTime.Parse(year.ToString() + GivenMonth); dt.Day = DateTime.DaysInMonth(year, GivenMonth);

        S 1 Reply Last reply
        0
        • C cppShooter

          a solution: int year = DateTime.Now.Year; DateTime dt = DateTime.Parse(year.ToString() + GivenMonth); dt.Day = DateTime.DaysInMonth(year, GivenMonth);

          S Offline
          S Offline
          Stefan Troschuetz
          wrote on last edited by
          #4

          I doubt this code will work. In line 2 you're using GivenMonth as a string and then in line 3 as a int.


          "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

          www.troschuetz.de

          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