473,379 Members | 1,170 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,379 software developers and data experts.

DateTime Field

My form includes a field of the DateTime type. I want to allow the user to
be able to set both the date and the time. By default the DateTimePicker
shows just the date and calendar, the time is autoset to 12:00 PM. How's
the best way to do this?

I tried creating a custom format which displays both the date and time and
turned on the Up Down option (DateTimePicker.ShowUpDown). This works but is
a bit clunky. The user has to click on each part of the field and then
either use the keyboard up down arrows or mouse-click the Up or Down arrows
on the control. I prefer my forms to be fully completable without the mouse
(though I do like mouse options available for those who want them). Tabbing
abandons the control rather than moving to the next portion of the field and
I don't see any way to control this behavior.

Another option I considered is 2 DateTimePicker controls on the form, both
tied to the same field, one for the Date and one for the Time. The problem
I forsee is that the data from each control could conflict. Just because
the date and time aren't displayed in each control doesn't mean they aren't
there.

Any tips appreciated.. thanks.

Ryan
Oct 17 '06 #1
2 1355
Ok for now what I decided to do was split the date and time into 2 fields.
Each field actually stores a date and time well because that's the way
Microsofts datetime field works, but the other stat is ignored (in other
words if its my date field the time portion is ignored and visa versa).
I'll go with this but still open to other suggestions.

"Ryan" <Ty****@newsgroups.nospamwrote in message
news:Ol****************@TK2MSFTNGP03.phx.gbl...
My form includes a field of the DateTime type. I want to allow the user
to be able to set both the date and the time. By default the
DateTimePicker shows just the date and calendar, the time is autoset to
12:00 PM. How's the best way to do this?

I tried creating a custom format which displays both the date and time and
turned on the Up Down option (DateTimePicker.ShowUpDown). This works but
is a bit clunky. The user has to click on each part of the field and then
either use the keyboard up down arrows or mouse-click the Up or Down
arrows on the control. I prefer my forms to be fully completable without
the mouse (though I do like mouse options available for those who want
them). Tabbing abandons the control rather than moving to the next
portion of the field and I don't see any way to control this behavior.

Another option I considered is 2 DateTimePicker controls on the form, both
tied to the same field, one for the Date and one for the Time. The
problem I forsee is that the data from each control could conflict. Just
because the date and time aren't displayed in each control doesn't mean
they aren't there.

Any tips appreciated.. thanks.

Ryan

Oct 17 '06 #2
Hi Ryan,

1. As you can see, to display the time in the DateTimePicker, we can
specify a CustomFormat and set Format to Custom to achieve this. Here I
used yyyy-MM-dd hh:mm:ss as the CustomFormat.

The Tab key is used to switch the focus between the controls. Since going
through each part of the Date/Time is within this control. The
DateTimePicker has defined the arrow keys to accomplish this. You can use
left/right key to move among the parts and use up/down key to adjust values.

2. If you are considering using 2 DateTimePickers to collection Date and
Time separately, you can use the first picker's date value and the second
picker's time value and combine them into a new datetime object. That will
do the same for you.

In my opinion, I suggest you try my first suggestion, because this can be
done with one control. If anything is unclear, please feel free to let me
know.

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Oct 18 '06 #3

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

Similar topics

2
by: andrew lowe | last post by:
Hi, Please bear with me on this problem, first I'll give you some background: I have an object that contains a DateTime field which i pass to a webservice public class Foo { public DateTime...
6
by: Carl | last post by:
Hi, to be use with SQL server database 1- From window form textbox object From this assignement, txtTOTAL.Text="0.00m"; How do you convert back to decimal type ? How do you assign a...
44
by: Frank Rizzo | last post by:
Any ideas?
6
by: FatboyCanteen | last post by:
When I using dataset to append a null value to the datetime field. It throw a error -> can not convert db.null to system.date Can there is any standard to pass a Null value to the DateTime...
1
by: Thierry | last post by:
Hi, I've got the next problem: I have a datetime field in my database (sql-server) and I want the option in it that this field can be empty. But if I leave that datetime field empty I get...
1
by: RML | last post by:
Hi everyone, I am using VB.NET 2003 and an OleDBDataAdapter to update an Access table's DateTime field. The field's format is set to "General Date" (ie: 11/24/2004 8:00:00 AM). The problem is...
4
by: kd | last post by:
Hi All, I have a datetime column in a table on the SQL database. I need to insert values into the datetime column from vb.net code. Here is my code: dim nameval, str, qry as string nameval =...
5
by: iulian.ilea | last post by:
Is correct to have a varchar field and insert dates of type dd/mm/yyyy into it? I choose this method because I have an application that runs on more than one server. So, if I used a datetime field...
3
by: john | last post by:
I am using MS Sql Express as the backend database for a Microsoft Access front end application. I am using a calendar control to store the desired date in the sql datetime field. The time...
4
by: Bill Gower | last post by:
Why won't this work? What do I need to do to make it work? DateTime? DateMember; if((DateTime.Parse(oldRow.ToString) == null)) DateMember = null; else DateMember =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.