Solved

Customised Calendar

Posted on 2007-03-23
2
175 Views
Last Modified: 2010-04-14
Hi experts, I would like to build a simple calendar on a seven rows by five columns table. It is used to fill in scheduled items. It is something like the datetimepicker control. I would like to know how to determine the first date so that I can start to fill the "cell".
0
Comment
Question by:novknow
  • 2
2 Comments
 
LVL 9

Expert Comment

by:ripahoratiu
ID: 18778895
You mean the first moday date in or out the month of a given date? Let's say you start with a known date: myDateTime (could be DateTime.Now)

            DateTime FirstDateOfMonth = myDateTime.AddDays(1-myDateTime.Day);
// FirstDateOfMonth contains the first date in month. If  you want to find out what's the day of week of
// the first of the month just ask it with FirstDateOfMonth.DayOfWeek
// if you want to complete to the first monday regradless of the start day of the month contineu with:
            DateTime FirstSundayToDisplay = FirstDateOfMonth;
            if (FirstDateOfMonth.DayOfWeek != DayOfWeek.Monday)
            {
                FirstSundayToDisplay = FirstDateOfMonth.AddDays(-(long)(FirstDateOfMonth.DayOfWeek));
            }


That's all...

0
 
LVL 9

Accepted Solution

by:
ripahoratiu earned 500 total points
ID: 18778912
....replace all apearences of word monday with sunday. The first sunday. In Europe the week begins monday :)
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question