By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,978 Members | 1,389 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,978 IT Pros & Developers. It's quick & easy.

Displaying Dates

P: n/a
I have a windows form with several fields. One of the fields is a date. I use
DateTimePicker to enter and format the date. In my SQL table the date si
stored as follows "01/10/2005" and this is what I wont. When I display the
date with a 'fill or select' this is what I get '01/10/2005 12:00'. What am
I doing wrong? Please Help.
--
Norm Bohana
Nov 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Norm,

You are doing nothing wrong. In SQL Server, the time is stored with the
date as well. As a matter of fact, the variable behind the date in your
date time picker has time information as well. However, the date time
picker only displays date information, and it drops the time information (or
rather, it doesn't give it any consideration when displaying it).

They are the same value. The reason you see 12:00 is that the 12:00 is
reflective of midnight on that day, which is technically the first moment of
that day.

Is there an error that you are getting, or is this just a general
concern?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"nbohana" <nb*****@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
I have a windows form with several fields. One of the fields is a date. I
use
DateTimePicker to enter and format the date. In my SQL table the date si
stored as follows "01/10/2005" and this is what I wont. When I display
the
date with a 'fill or select' this is what I get '01/10/2005 12:00'. What
am
I doing wrong? Please Help.
--
Norm Bohana

Nov 17 '05 #2

P: n/a
I would like to remove the time from the textbox. This what I do in
DateTimePicker!

dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MM/dd/yyyy";
txtDate.Text = dateTimePicker1.Text;

--
Norm Bohana
"Nicholas Paldino [.NET/C# MVP]" wrote:
Norm,

You are doing nothing wrong. In SQL Server, the time is stored with the
date as well. As a matter of fact, the variable behind the date in your
date time picker has time information as well. However, the date time
picker only displays date information, and it drops the time information (or
rather, it doesn't give it any consideration when displaying it).

They are the same value. The reason you see 12:00 is that the 12:00 is
reflective of midnight on that day, which is technically the first moment of
that day.

Is there an error that you are getting, or is this just a general
concern?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"nbohana" <nb*****@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
I have a windows form with several fields. One of the fields is a date. I
use
DateTimePicker to enter and format the date. In my SQL table the date si
stored as follows "01/10/2005" and this is what I wont. When I display
the
date with a 'fill or select' this is what I get '01/10/2005 12:00'. What
am
I doing wrong? Please Help.
--
Norm Bohana


Nov 17 '05 #3

P: n/a
Ahh, you didn't mention that you were binding it to a textbox.

When you create the binding, what you can do is subscribe to the Parse
and the Format events on the binding. You can use this to format the date
as you wish in the textbox, as well as parse the date when the text is set
and needs to be persisted back to the value.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"nbohana" <nb*****@discussions.microsoft.com> wrote in message
news:D9**********************************@microsof t.com...
I would like to remove the time from the textbox. This what I do in
DateTimePicker!

dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MM/dd/yyyy";
txtDate.Text = dateTimePicker1.Text;

--
Norm Bohana
"Nicholas Paldino [.NET/C# MVP]" wrote:
Norm,

You are doing nothing wrong. In SQL Server, the time is stored with
the
date as well. As a matter of fact, the variable behind the date in your
date time picker has time information as well. However, the date time
picker only displays date information, and it drops the time information
(or
rather, it doesn't give it any consideration when displaying it).

They are the same value. The reason you see 12:00 is that the 12:00
is
reflective of midnight on that day, which is technically the first moment
of
that day.

Is there an error that you are getting, or is this just a general
concern?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"nbohana" <nb*****@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
>I have a windows form with several fields. One of the fields is a date.
>I
>use
> DateTimePicker to enter and format the date. In my SQL table the date
> si
> stored as follows "01/10/2005" and this is what I wont. When I display
> the
> date with a 'fill or select' this is what I get '01/10/2005 12:00'.
> What
> am
> I doing wrong? Please Help.
> --
> Norm Bohana


Nov 17 '05 #4

P: n/a
I am sorry, Thanks much.
--
Norm Bohana
"Nicholas Paldino [.NET/C# MVP]" wrote:
Ahh, you didn't mention that you were binding it to a textbox.

When you create the binding, what you can do is subscribe to the Parse
and the Format events on the binding. You can use this to format the date
as you wish in the textbox, as well as parse the date when the text is set
and needs to be persisted back to the value.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"nbohana" <nb*****@discussions.microsoft.com> wrote in message
news:D9**********************************@microsof t.com...
I would like to remove the time from the textbox. This what I do in
DateTimePicker!

dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MM/dd/yyyy";
txtDate.Text = dateTimePicker1.Text;

--
Norm Bohana
"Nicholas Paldino [.NET/C# MVP]" wrote:
Norm,

You are doing nothing wrong. In SQL Server, the time is stored with
the
date as well. As a matter of fact, the variable behind the date in your
date time picker has time information as well. However, the date time
picker only displays date information, and it drops the time information
(or
rather, it doesn't give it any consideration when displaying it).

They are the same value. The reason you see 12:00 is that the 12:00
is
reflective of midnight on that day, which is technically the first moment
of
that day.

Is there an error that you are getting, or is this just a general
concern?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"nbohana" <nb*****@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
>I have a windows form with several fields. One of the fields is a date.
>I
>use
> DateTimePicker to enter and format the date. In my SQL table the date
> si
> stored as follows "01/10/2005" and this is what I wont. When I display
> the
> date with a 'fill or select' this is what I get '01/10/2005 12:00'.
> What
> am
> I doing wrong? Please Help.
> --
> Norm Bohana


Nov 17 '05 #5

P: n/a
Nicholas, I am sorry, I cannot find out how to implement your suggestion. I
found the events ok, but I do not know how to setup it up in the textbox.
Can you point me in the right direction please!!
--
Norm Bohana
"Nicholas Paldino [.NET/C# MVP]" wrote:
Ahh, you didn't mention that you were binding it to a textbox.

When you create the binding, what you can do is subscribe to the Parse
and the Format events on the binding. You can use this to format the date
as you wish in the textbox, as well as parse the date when the text is set
and needs to be persisted back to the value.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"nbohana" <nb*****@discussions.microsoft.com> wrote in message
news:D9**********************************@microsof t.com...
I would like to remove the time from the textbox. This what I do in
DateTimePicker!

dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MM/dd/yyyy";
txtDate.Text = dateTimePicker1.Text;

--
Norm Bohana
"Nicholas Paldino [.NET/C# MVP]" wrote:
Norm,

You are doing nothing wrong. In SQL Server, the time is stored with
the
date as well. As a matter of fact, the variable behind the date in your
date time picker has time information as well. However, the date time
picker only displays date information, and it drops the time information
(or
rather, it doesn't give it any consideration when displaying it).

They are the same value. The reason you see 12:00 is that the 12:00
is
reflective of midnight on that day, which is technically the first moment
of
that day.

Is there an error that you are getting, or is this just a general
concern?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"nbohana" <nb*****@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
>I have a windows form with several fields. One of the fields is a date.
>I
>use
> DateTimePicker to enter and format the date. In my SQL table the date
> si
> stored as follows "01/10/2005" and this is what I wont. When I display
> the
> date with a 'fill or select' this is what I get '01/10/2005 12:00'.
> What
> am
> I doing wrong? Please Help.
> --
> Norm Bohana


Nov 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.