473,513 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TimeOfDay adds 1/1/0001 to the Time value?

Hello,

I have a label in my app where I display time from a Timer contol like this:

Private Sub Timer1_Tick(...) Handles Timer1.Tick
lbl_Time.Text = TimeOfDay.ToString
End Sub

The display is 1/1/0001 10:00:01 AM

How can I remove the 1/1/0001 part?

Thanks,
Rich
Feb 1 '06 #1
6 4681
Hmmm, I tried

TimeOfDay.ToShortTime.ToString

which seems to display just the time value 10:07 AM but no seconds. Any
suggestions appreciated how I can display a time value in this form:

10:07:23 AM
"Rich" wrote:
Hello,

I have a label in my app where I display time from a Timer contol like this:

Private Sub Timer1_Tick(...) Handles Timer1.Tick
lbl_Time.Text = TimeOfDay.ToString
End Sub

The display is 1/1/0001 10:00:01 AM

How can I remove the 1/1/0001 part?

Thanks,
Rich

Feb 1 '06 #2
"Rich" <Ri**@discussions.microsoft.com> schrieb
Hello,

I have a label in my app where I display time from a Timer contol
like this:

Private Sub Timer1_Tick(...) Handles Timer1.Tick
lbl_Time.Text = TimeOfDay.ToString
End Sub

The display is 1/1/0001 10:00:01 AM

How can I remove the 1/1/0001 part?

ToString is overloaded. Use one of the other versions.

Also consider using Date.TimeOfDay. Returns a TimeSpan object with no
formatting features with the ToString method, but doesn't contain a Date
part.
Armin

Feb 1 '06 #3
Rich,

TimeOfDay.ToLongTimeString

Kerry Moorman
"Rich" wrote:
Hmmm, I tried

TimeOfDay.ToShortTime.ToString

which seems to display just the time value 10:07 AM but no seconds. Any
suggestions appreciated how I can display a time value in this form:

10:07:23 AM
"Rich" wrote:
Hello,

I have a label in my app where I display time from a Timer contol like this:

Private Sub Timer1_Tick(...) Handles Timer1.Tick
lbl_Time.Text = TimeOfDay.ToString
End Sub

The display is 1/1/0001 10:00:01 AM

How can I remove the 1/1/0001 part?

Thanks,
Rich

Feb 1 '06 #4
Thanks all for your replies.

"Rich" wrote:
Hello,

I have a label in my app where I display time from a Timer contol like this:

Private Sub Timer1_Tick(...) Handles Timer1.Tick
lbl_Time.Text = TimeOfDay.ToString
End Sub

The display is 1/1/0001 10:00:01 AM

How can I remove the 1/1/0001 part?

Thanks,
Rich

Feb 1 '06 #5
How about this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Label1.Text = TimeOfDay.ToString("hh:mm:ss tt")

End Sub

That will give the current time showing only AM/PM instead of the date.
(modify to work with your timer)
james
"Rich" <Ri**@discussions.microsoft.com> wrote in message
news:DC**********************************@microsof t.com...
Hello,

I have a label in my app where I display time from a Timer contol like
this:

Private Sub Timer1_Tick(...) Handles Timer1.Tick
lbl_Time.Text = TimeOfDay.ToString
End Sub

The display is 1/1/0001 10:00:01 AM

How can I remove the 1/1/0001 part?

Thanks,
Rich

Feb 1 '06 #6
Or even better: (sorry for answering my own response)

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Timer1.Tick

Label1.Text = TimeOfDay.ToString("hh:mm:ss tt")

End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load

Timer1.Interval = 100

Timer1.Enabled = True

End Sub
james

"james" <jj***************@earthlink.net> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
How about this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Label1.Text = TimeOfDay.ToString("hh:mm:ss tt")

End Sub

That will give the current time showing only AM/PM instead of the date.
(modify to work with your timer)
james
"Rich" <Ri**@discussions.microsoft.com> wrote in message
news:DC**********************************@microsof t.com...
Hello,

I have a label in my app where I display time from a Timer contol like
this:

Private Sub Timer1_Tick(...) Handles Timer1.Tick
lbl_Time.Text = TimeOfDay.ToString
End Sub

The display is 1/1/0001 10:00:01 AM

How can I remove the 1/1/0001 part?

Thanks,
Rich


Feb 1 '06 #7

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

Similar topics

1
1614
by: Pavel Stehule | last post by:
Hello In this version I can't convert returned value to time. timeofday() return text. I need convert to timestamp before. It is normal behavior? I expected timestamp as returned type. ...
0
1707
by: Jason Priebe | last post by:
I posted earlier with a very complex example. This simple one gets to the point much faster. timeofday() seems to behave inconsistently when the timezone is set with "GMT+X" notation. foo=>...
2
5822
by: Vilson farias | last post by:
Greetings, I was executing some queries when I discovered that 7.3.4's CAST is a little different from 7.1.2 when working with timestamps. When working with localized timestamps, I can't use...
7
5106
by: smcgouga | last post by:
Visual Basic 6. ADO 2.8 I have an as400 DB2 V5R1 datasource. Dates are defined as *ISO format and have a range from '0001-01-01' to '9999-12-31'. I am trying to update a date field on the...
1
2980
by: Reza | last post by:
Hi I have a column in my datagrid that can have values of null at times. I am not assigning any value to it, if it is coming from Database empty. Now, the problem is I guess the datetime variables...
4
1720
by: Peter | last post by:
Hi I am using DateTime class and TimeOfDay.Hours attribute to return current time. It returns right value on two servers, but in one particular server it does not return right time. I checked that...
2
2864
by: Johannes Hammersen | last post by:
Hi, when I try to set the Minimum Date on a RangeValidator to 01.01.0001 I get an error, that 01.01.0001 can not be converted to a date. But the DateType can be 01.01.0001....
5
5216
by: Tan | last post by:
I am using ObjectDataSource bind to DetailView which will contain one of the column with the value type is date. whenver the value of this column is empty . then it will be display the date in the...
1
2613
Cyberdyne
by: Cyberdyne | last post by:
Hi Guys I am working on a database that will have a locked auto field with the following characteristics. It has to be a number that will be stored in a table, it needs to have the following format ...
0
7264
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,...
0
7386
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
7543
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...
1
7106
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...
0
7534
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5094
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1601
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 ...
0
459
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.