Solved

Customised Calendar

Posted on 2007-03-23
2
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Check only one toolstripmenu item 12 63
Adjust the codes 3 65
Put File 6 38
Example code 13 45
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…

710 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