In mysql, this statement gives a negative answer, meaning the start is a later time than the end. This won't work in C, because the hour variable is unsigned. Does anyone know of another way to tell whether or not a time comes before another time..
Thanks
Bob
The statement I used was
SELECT TIMEDIFF('01:00 :00','02:00:00' );
returns -01:00:00 in mysql, and 01:00:00 in C
3 2056 Atli 5,058
Recognized Expert Expert
Hi.
In MySQL the TIMEDIFF() function subtracts the second parameter from the first parameter and returns the result as a time value.
I can only guess that it works the other way around in C, unless it only returns absolute values?
pbmods 5,821
Recognized Expert Expert
Heya, Bob.
Is it possible to declare the hour variable as signed?
Alternatively you could try TIME_TO_SEC(). Then at least you can compare and see if value 1 is less than value 2.
Found the answer elsewhere, it turns out that if there's a negative value returned by mysql, the C api shows it without the sign(the hour variable is unsigned in the C api), and the negative part of the answer is put in a boolean variable called neg attached to the MYSQL_TIME structure. Now I just need to make it work. Neg is always 1, whether the answer should be or not.
Bob
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Andie |
last post by:
Hello All,
I have this sql statement thats works in MSSQL when I call a function
function showNewProd(dispNum)
'Declare some variables
dim mySQL, rsTemp, tempStr, count
'Read Database
|
by: Hans |
last post by:
Hello group,
I have a table with the next contents.
It lists data about : Who sent what kind of message at what time.
For the Level column: The highest level is Critical, the middle is Warning,
the lowest is Info.
Id Timestamp Level
1 12:00 Info
1 13:00 Warning
|
by: James E Koehler |
last post by:
I can't get the WHILE statement to work in MySQL.
The version of MySQL that I am using is:
Ver 12.16 Distrib 4.0.6-gamma, for Win95/Win98 (i32)
running on Windows MX.
Here is the relevant section from the manual:
20.1.9.7 WHILE Statement
|
by: Dan |
last post by:
Hello,
Am trying to construct a query that'll both compute elapsed time based
on certain criteria and sum this up for a subset of records.
Sample Data that I'm working with:
Row Ev_Time Ev_id Ev_Desc
-------------------------------------------------------------------
1 2004-12-03 14:28:45 400 Batch set Run
|
by: phil |
last post by:
I am having a problem with the C api with prepared statements, the data
recorded in the database does not match the data I am sending. It seems to
be some sort of bit shifted version of the data, and I have no idea why.
I am including code I have been using to test this, followed by the output
in the database.
I am using mysql version 4.1.12,
I have tried this on multiple servers, remote and local.
| |
by: Alicia |
last post by:
Does anyone know why I am getting a "Syntax error in Create Table
statement". I am using Microsoft Access SQL View to enter it. Any
other problems I may run into?
CREATE TABLE weeks
(
weekstart datetime not null primary key,
weekend datetime not null
)
|
by: chrisdebritain |
last post by:
Hello,
I am trying to construct a query to be run against a timestamp so that
data is displayed from a certain time backwards. For example:
SELECT Time_Stamp, Park_Name, Mill_Name, Size, Email_Type FROM emails
WHERE TIMEDIFF(NOW(),Time_Stamp) <= '96:00:00' ORDER BY Time_Stamp
LIMIT 0, 30
This would theoretically pull all the records from this moment until 4
|
by: Ryan Liu |
last post by:
Hi,
I downloaded the latest version of mysql 5.0 and its .NET driver, I copied
the sample code from mysql 5.0 manual to do use prepared statement in C#.
But indeed I got a run time error say that "#42000You have an error in your
SQL syntax; ..."
I tried variuos format and I get regular statement(with parameters) and
stored procedure works fine in my c# code, but just not for cmd.Prepare().
|
by: manmadhan |
last post by:
i refer lots of website for "timediff mysql function not working in gridview" , its working mysql tool but in asp.net gridview its not working.... please any one help me for this problem
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |