473,761 Members | 8,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1375
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****@newsgro ups.nospamwrote in message
news:Ol******** ********@TK2MSF TNGP03.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
14275
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 RequestDate; }
6
1818
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 default datetime value to it ? How do you convert back the text enter by user into datetime ?
44
17008
by: Frank Rizzo | last post by:
Any ideas?
6
16264
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 Field! (It is successful to pass the Null Value to other type of Field)
1
1999
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 the error: "The value you entered is not consistent with the data type or length of the column."
1
4789
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 the field ends up with only a date, with no time component. In my project... I added an OleDBDataAdapter using the wizzard to my form. I generated the DataSet and added the desired table. I verified the field type in the
4
4604
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 = "abc" str = "2005/03/16 14:20" qry = "insert into tab1(name,dateval) values(" & "'" & nameval & "'," & "'" str & "')" ....
5
2601
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 (MSSQL Server) it worked on my test machine. If I run the same application on another machine with different regional settings is not working. I tried with date_default_timezone_set to change timezone but is not changing. After...
3
5320
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 portion of the field defaults to 12:00am. What I want is to also store the time in the same datetime field as the date, but I want to use a separate control from the calendar control. I.e. I want the user to choose the date from the calendar control,...
4
10698
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 = DateTime.Parse(oldRow.ToString()); The program is failing on the if saying that the null value in the field in
0
9531
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9957
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8780
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5229
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.