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

time of day to seconds

I am working with a very old database system (building an import/export routine) that stores the time in seconds. I have been
able to convert the seconds to correct time (thanks to a lot of help in this group).
But, I need to be able to write back the time of day to the db in seconds.
Example:
01:00:00 PM should be 46800 seconds.

I can get it to work in an odd sort of way like this:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim dt As Integer

dt = New Date().Subtract(TextBox2.Text).TotalSeconds.ToStri ng

TextBox1.Text = dt.ToString

End Sub

But, if you run this and have the above time in Textbox2 ( 01:00:00 PM) it will show -46800 seconds in Textbox1.

I have tried several variations of the Date function, but, it appears that only the .Subtract function has the .TotalSeconds
function.

And as noted, it gives a negitive number instead of a postive number.

Any suggestions ? ( besides running as far away from the DOS based Dataflex database as I can :-)

james


Dec 30 '05 #1
3 2975
I knew it, as soon as I posted this, I would find the answer (not always that way though).

Here is what I came up with, not too complicated, and works:

Dim dt As Date

dt = TextBox2.Text

TextBox1.Text = (dt.Ticks / 10000000).ToString
Tested and so far, works good. I'm sure I will find a way to kill it ( if my users don't first!)
james

"james" <jjames700ReMoVeMe at earthlink dot net> wrote in message news:eZ*************@TK2MSFTNGP14.phx.gbl...
I am working with a very old database system (building an import/export routine) that stores the time in seconds. I have been
able to convert the seconds to correct time (thanks to a lot of help in this group).
But, I need to be able to write back the time of day to the db in seconds.
Example:
01:00:00 PM should be 46800 seconds.

I can get it to work in an odd sort of way like this:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim dt As Integer

dt = New Date().Subtract(TextBox2.Text).TotalSeconds.ToStri ng

TextBox1.Text = dt.ToString

End Sub

But, if you run this and have the above time in Textbox2 ( 01:00:00 PM) it will show -46800 seconds in Textbox1.

I have tried several variations of the Date function, but, it appears that only the .Subtract function has the .TotalSeconds
function.

And as noted, it gives a negitive number instead of a postive number.

Any suggestions ? ( besides running as far away from the DOS based Dataflex database as I can :-)

james

Dec 30 '05 #2
"james" <jjames700ReMoVeMe at earthlink dot net> schrieb:
I am working with a very old database system (building an import/export
routine) that stores the time in seconds. I have been able to convert the
seconds to correct time (thanks to a lot of help in this group).
But, I need to be able to write back the time of day to the db in seconds.
Example:
01:00:00 PM should be 46800 seconds.


\\\
Dim d As Date = #01:00:00 PM#
MsgBox(CStr(d.TimeOfDay.TotalSeconds))
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 30 '05 #3

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:uo**************@TK2MSFTNGP12.phx.gbl...
\\\
Dim d As Date = #01:00:00 PM#
MsgBox(CStr(d.TimeOfDay.TotalSeconds))
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Thanks Herfried, an even better (and shorter) way to do it.
james

Dec 30 '05 #4

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

Similar topics

15
by: kpp9c | last post by:
I am kind of in a bit of a jam (okay a big jam) and i was hoping that someone here could give me a quick hand. I had a few pages of time calculations to do. So, i just started in on them typing...
77
by: Charles Law | last post by:
Hi guys I have a time critical process, running on a worker thread. By "time critical", I mean that certain parts of the process must be completed in a specific time frame. The time when the...
5
by: Tom | last post by:
A field in a data set I want to import into Access is in Unix time (seconds from a certain time on a certain date). Does anyone know the precise date and the precise time on that date that Unix is...
5
by: Sinan Nalkaya | last post by:
hello, i need a function like that, wait 5 seconds: (during wait) do the function but function waits for keyboard input so if you dont enter any it waits forever. i tried time.sleep() but when...
5
by: Summu82 | last post by:
HI I have to convert a time in the format i have year month day hour min and seconds I need to convert this into time in seconds since 1 jan 1970 i.e the
7
by: nono909 | last post by:
I wrote the following time class for the following assignment.i need help in completing this program pleasee. Write a class to hold time. Time is the hour, minute and seconds. Write a constructor...
3
by: Paul McGuire | last post by:
I am doing some simple timing of some elements of Python scripts, and the simplest is to just call time.time() before and after key elements of the script: t1 = time.time() # do lengthy...
37
by: David T. Ashley | last post by:
I have Red Hat Enterprise Linux 4. I was just reading up about UTC and leap seconds. Is it true on my system that the Unix time may skip up or down by one second at midnight when there is a...
8
by: Theo v. Werkhoven | last post by:
hi, In this code I read out an instrument during a user determined period, and save the relative time of the sample (since the start of the test) and the readback value in a csv file. #v+...
0
by: Hendrik van Rooyen | last post by:
Lawrence D'Oliveiro wrote: The above is an endless loop, doing something every five seconds, and something else in the in between times. I don't think you are dense - its a good point,...
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...
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...
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...

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.