473,388 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

DateTimePicker formatting

Hi All

I am using DateTimePicker Control in my application.
On form Load i want to set the value in the DateTimePicker to nearest
coming Sunday.

Can anyone suggest me how to do it ????

Warm Regards
Sumit

Nov 16 '05 #1
3 3527
Hi Sumit
Check out this sample extended DataTimePicker
http://www.thecodeproject.com/cs/mis...timepicker.asp

Mohamed M .Mahfouz
Developer Support Engineer
ITWorx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #2
Sumit,

Is that not simpel using the dayofweek property of datetime and with the
datetime.adddays(the days to go)?

http://msdn.microsoft.com/library/de...classtopic.asp

http://msdn.microsoft.com/library/de...fweektopic.asp

Cor
Nov 16 '05 #3
Agreed. It's crude, but this should work.

DateTime dt = DateTime.Today;
while (dt.DayOfWeek != DayOfWeek.Sunday){
dt.AddDays(1);
}
dtp.Value = dt;

Hope this helps,

Dan Cox

"Cor Ligthert" <no************@planet.nl> wrote in message
news:e4**************@tk2msftngp13.phx.gbl...
Sumit,

Is that not simpel using the dayofweek property of datetime and with the
datetime.adddays(the days to go)?

http://msdn.microsoft.com/library/de...classtopic.asp

http://msdn.microsoft.com/library/de...fweektopic.asp

Cor



Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
0
by: Sumit | last post by:
Hi all, I have a datetimepicker on my windows form. When the user selects it i check whether the date entered is a Sunday or not & if its not a sunday i want that the control remains on the...
4
by: Jacek Jurkowski | last post by:
.... the minimum date of DateTimePicker is 1753-01-01. How to make DateTime to do not show nothing in its text if this date is the value? I have a form with a field LastLogonDate. If user hasn't...
1
by: Aaron Smith | last post by:
How do you get the datetimepicker to save only the time to a databound field? I have tried format and parse, and the functions work, getting the cevent.value = "1:25 PM" but it always saves the...
7
by: Clamara | last post by:
When adding a new record from my form, I pre-set my DateTimePicker's value to System.DateTime.Today Since the "Today" value is used most of the time, the user doesn't need to select a date from...
3
by: Charlie | last post by:
In the top portion of the DateTimePicker, where the value of the date is displayed, how can I detect whether the month or day or year is currently focused, or, if ShowCheckBox = True, whether the...
3
by: Simon Tamman | last post by:
I've come across an interesting bug. I have workarounds but i'd like to know the root of the problem. I've stripped it down into a short file and hope someone might have an idea about what's going...
5
by: Terry | last post by:
My system short date format is dd/mm/yy. The DateTimePicker returns mm/dd/yyyy hh:mm:ss PM. I need to get this value formated into dd/mm/yyyy regardless of the system short date format, what...
4
by: =?Utf-8?B?VGVycnk=?= | last post by:
Converting an old application and came accross a funny problem. Have a subscription DB with a renewal date field. If the subscription is considered a 'freebee', then it never has to be renewed...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.