473,411 Members | 2,272 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,411 software developers and data experts.

I have a TIMEDIFF statement that works in MYSQL, but not in C

13
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
Aug 20 '07 #1
3 2028
Atli
5,058 Expert 4TB
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?
Aug 22 '07 #2
pbmods
5,821 Expert 4TB
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.
Aug 22 '07 #3
bsm2th
13
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
Aug 22 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

16
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
6
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,...
4
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...
3
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 ...
0
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,...
2
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 (...
6
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,...
0
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...
1
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
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
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:
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:
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
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,...
0
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
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...

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.