how to find dates of sundays in a year using c#?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nirmalsingh
    New Member
    • Sep 2006
    • 218

    how to find dates of sundays in a year using c#?

    hi all!
    i have to find the dates of sundays in a year. help me with sample code in C#.
    thanx in advance.
  • prabunewindia
    New Member
    • Mar 2007
    • 199

    #2
    hi friend,
    there is a property (read only) for a datetime variable called "day"
    check it and print the date
    if(dateToday.Da y=="sunday")
    {
    print dateToday;
    }

    this is not code, just i wrote the method

    Originally posted by nirmalsingh
    hi all!
    i have to find the dates of sundays in a year. help me with sample code in C#.
    thanx in advance.

    Comment

    • nirmalsingh
      New Member
      • Sep 2006
      • 218

      #3
      Originally posted by prabunewindia
      hi friend,
      there is a property (read only) for a datetime variable called "day"
      check it and print the date
      if(dateToday.Da y=="sunday")
      {
      print dateToday;
      }

      this is not code, just i wrote the method
      i am in need of full list of dates that comes in sundays in a year.

      Comment

      • prabunewindia
        New Member
        • Mar 2007
        • 199

        #4
        check it for sunday
        if(date.day=="s unday")
        {
        /// code to get it or store in database or print in listbox
        }
        Originally posted by nirmalsingh
        i am in need of full list of dates that comes in sundays in a year.

        Comment

        • vanc
          Recognized Expert New Member
          • Mar 2007
          • 211

          #5
          this is may not a very good idea but it should work :D

          for month = 1 to 12 in year
          {
          get three first dates of month (1st,2nd,3rd)

          if DaysInMonth == 30 and (1stdate == "Sunday" or 2nddate == "Sunday")
          Number of Sunday += 5;
          else if DaysInMonth == 31 and (1stdate == "Sunday" or 2nddate == "Sunday" or 3rddate == "Sunday")
          Number of Sunday += 5;
          else
          Number of Sunday += 4;
          }

          cheers.

          Comment

          Working...