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. Web Development
  3. ASP.NET
  4. Finding the Day of the Week a date starts on

Finding the Day of the Week a date starts on

Scheduled Pinned Locked Moved ASP.NET
question
2 Posts 2 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.
  • J Offline
    J Offline
    jamesbronw
    wrote on last edited by
    #1

    Hey, I need to find out what day of the week the first day of each month starts on. Is there a way to do this? Or does anyone have any ideas of how i could write a function in order to find this out? Thanks in advanced Tommy

    J 1 Reply Last reply
    0
    • J jamesbronw

      Hey, I need to find out what day of the week the first day of each month starts on. Is there a way to do this? Or does anyone have any ideas of how i could write a function in order to find this out? Thanks in advanced Tommy

      J Offline
      J Offline
      Jesse Squire
      wrote on last edited by
      #2

      I'd recommend that the first step for you would be to take a peek at the availible members of the DateTime type in the MSDN documentation. Each member ususally has an example snipit of code, which may prove helpful. In particular, look for the DayOfWeek property. Using that property, you can easily determine the day of the week for any given date. My very quick and dirty proof of concept for finding the first day of each month:

      protected override void OnLoad(System.EventArgs ea)

      {

      DateTime first = DateTime.Parse("01/01/2005");

      DayOfWeek day = first.DayOfWeek;

      Response.Write(first.ToString("MMMM") + ": " + day.ToString() + "<br />");

      for (int index = 0; index < 11; index++)

      {

      first = first.AddMonths(1);

      day = first.DayOfWeek;

      Response.Write(first.ToString("MMMM") + ": " + day.ToString() + "<br />");

      }

      }

      Hope that helps. :) --Jesse

      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