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

Help with Date Time formatting and comparison

I have an application that stores the time information received via the
serial port from some hardware.

The application needs to compare this time gainst the time received in the
last packet and see if the difference is greater than a timeout period that
is stored in a database record for that hardware.

The data comes in as bytes that are packed BCD values in 24 hour format. ie.
2:15:00 pm would be received as 14h 15h 00h

Firstly, is there a simple way to turn the incoming data from the databuf
into a string ? In C I can just add a null character to the buffer and
select the start position like mystr = databuf + 3

Secondly, what would be the most efficient way of converting this into a
time only value that could be stored in the database and easily compared to
the next value + timeout period.

ie. Process needs to do this.

if TimeValue in received packet > Lastsaved Time + Timeout period then do
something
Lastsaved time = timevalue in this packet

Thanks heaps
Nov 21 '05 #1
2 1106
David,

The datetime is for me the best format to handle dates. Avoid any string
comparising because that is direct culture dependend.

dim mydate as datetime = new datetime(year,mont,day,hour,minutes,seconds)

Gives an for every culture proper date and is when used together with the
timespan very good for comparing.

I hope this helps?

Cor
Nov 21 '05 #2
Thanks

"Cor Ligthert" <no************@planet.nl> wrote in message
news:OU****************@TK2MSFTNGP12.phx.gbl...
David,

The datetime is for me the best format to handle dates. Avoid any string
comparising because that is direct culture dependend.

dim mydate as datetime = new datetime(year,mont,day,hour,minutes,seconds)

Gives an for every culture proper date and is when used together with the
timespan very good for comparing.

I hope this helps?

Cor

Nov 21 '05 #3

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

Similar topics

9
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my...
11
by: The_Kingpin | last post by:
Hi all, I'm new to C programming and looking for some help. I have a homework project to do and could use every tips, advises, code sample and references I can get. Here's what I need to do....
4
by: Darryn Ross | last post by:
Hi, i am trying to run a simple SQL statement from my C# app to return a number of records, however when i do my record count is always zero, but i know there are transactions in there... My...
2
by: johndcal | last post by:
Hello All, I have a date value that I pull from a .csv file. After reading the file and storing the values in an array the value of the date could be found in $array, for example....
26
by: jshanman | last post by:
I am writing a timeline that uses Google Maps. I have a function that converts a date time to latitude coords. This function is used to draw the markers on the timeline. I need a reverse function...
5
by: Gordon Youd | last post by:
Randy Harris and Bob Quintal have tried to help me with my data base report problem, for which I thank them. The suggestions they gave me still do not seem to work and I am still getting false...
16
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
3
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
1
by: jonny | last post by:
Option Explicit Private mdTarget1 As Date Private mdTarget2 As Date ' called on form load Public Sub SetRecordStartTime() mdTarget1 = DateAdd("n", 60, Time) mdTarget2 = DateAdd("n", 120,...
6
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I am trying to compare just the time portion of two variables that are of date time part. For example I have dtdate1= 2/2/07 10:00:00 dtdate2=3/4/07 9:00:00 so for the comparision I would...
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
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
0
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
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...

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.