473,699 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1126
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,m ont,day,hour,mi nutes,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******** ********@TK2MSF TNGP12.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,m ont,day,hour,mi nutes,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
4351
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 predecessor, I hasten to add) so that each day it creates a copy of the record for each company, changes the date to today's date, and prompts the user for any changes of ratings on that day. The resulting data table grows by approx 600 records per...
11
1990
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. I have a file named books.txt that contains all the informations on the books. Each book is a struc containing 6 fields written on separated line in the
4
1183
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 code is as follows... "SELECT * FROM " + Table + " WHERE Date >=" + "#" + DateFrom.ToShortDateString() + "#" + " And " + " Date <=" + "#" + DateTo.ToShortDateString() + "#"
2
2162
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. ============================================================= while (($data = fgetcsv($handle,5000, ",")) !== FALSE) { $mydate = $data; // here is the array value that holds the date }
26
2712
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 to convert a latitude coord back to an accurate date time. Then I could detect the day/hour in the viewport when the timeline is zoomed in or out, or if it is moved. I cannot use the javascript date functions because this timeline will...
5
1512
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 data showing. Data base is of customers who book a car to pick them up on a certain date to take them to an Airport. They would also book a car for thier return on a date in the future.
16
2805
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 efficient navigating within Visual Studio 2005. Let's say your project (or solution) has dozens of forms and hundreds or even thousands of routines. Two Questions: 1) BUILT-IN to Visual Studio 2005. What ideas do you have to quickly
3
3300
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 the field should only be showing one or the other (date or time). Even on the back end of the database where the column properties are, I have chosen the smallest date/time formats. When the aspx page runs, it shows the date and time (ie:in a...
1
1677
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, Time)
6
2585
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 want 10:00:00 cmp with 9:00:00 so ddate1>ddate2 is true. I tried converting to short time string but the comparison can not be done on the strings. Thanks Paul. --
0
9173
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...
1
8911
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7748
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
5872
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4375
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
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
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
2
2345
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.