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

absolute value fro timestamps

Hello

Evidently is possible to have a negative time interval:

clapidus=> select interval '-1';
interval
-----------
-01:00:00

However, there seems to be no provision to get the absolute value in such
case:

clapidus=> select @ interval '-1';
ERROR: operator does not exist: @ interval
HINT: No operator matches the given name and argument type(s). You may need
to add explicit typecasts.

clapidus=> select abs(interval '-1');
ERROR: function abs(interval) does not exist
HINT: No function matches the given name and argument types. You may need
to add explicit typecasts.

What did I miss this time?

PGversion is 7.4b2

cl.
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 11 '05 #1
2 3524
Claudio Lapidus wrote:
Hello

Evidently is possible to have a negative time interval:

clapidus=> select interval '-1';
interval
-----------
-01:00:00

However, there seems to be no provision to get the absolute value in such
case:

clapidus=> select @ interval '-1';
ERROR: operator does not exist: @ interval
HINT: No operator matches the given name and argument type(s). You may need
to add explicit typecasts.

clapidus=> select abs(interval '-1');
ERROR: function abs(interval) does not exist
HINT: No function matches the given name and argument types. You may need
to add explicit typecasts.

What did I miss this time?


Why would you want an abolute value of a negative interval?

This works:

test=> select -(interval '-1');
?column?
----------
01:00:00
(1 row)

so I suppose you could create a function or CASE statement to get the
absolute value.

--
Bruce Momjian | http://candle.pha.pa.us
pg***@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 11 '05 #2
"Claudio Lapidus" <cl******@hotmail.com> writes:
Bruce Momjian wrote:
Why would you want an abolute value of a negative interval?
Because I'm trying to match pairs of records that satisfy certain criteria,


Given that we have a unary-minus operator for intervals, I see no
conceptual objection to having an absolute-value operator (and \do shows
that interval is the only standard datatype that has the former but not
the latter).

However, given that it doesn't seem to be a really widely useful
operator, I think this is the kind of itch that you'll have to scratch
yourself. Send us a patch and it'll get into the next release ...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 11 '05 #3

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

Similar topics

7
by: lkrubner | last post by:
This might be an idiot question, but how do you group by timestamps by date? I mean, given a large number of timestamps, spanning many months, how do grab them and say how many are from each day?...
2
by: Joachim Bauer | last post by:
I'm using the code below to display a menu that opens when the mouse goes over the main menu item (try it in your browser to understand the behaviour). It uses "position:absolute" and a switch...
10
by: Craig Wahlmeier | last post by:
Am I the only one in the world that selects dates and timestamps with OLEDB? V8 of UDB has brought me a big problem. The PATCH2=24 setting no longer works the way it used to. The settings of...
5
by: Robert Schuldenfrei | last post by:
Dear NG, I have not heard from anyone about a good book that deals with the concurrency issue in SQL Server using C#. I have PROMISED Nick I would not use record locking and I have used an old...
2
by: Chumma Dede | last post by:
Hi, I need to code a DLL in .NET which logs the response times for our asp.net multi-tier application. The problem is we need to log the timestamps at multiple stages in a process lifecycle...
4
by: Craig G | last post by:
im not too sure how i should be storing the SQL2000 timestamps basically i return a dataset which is used to populate an editable grid. this dataset contains the timestamp. how should i be...
0
by: mikek | last post by:
Good Morning from Detroit, I am working on a project to Connect and manipulatee data in a SQLServer Data base, from a LINUX server using PERL. and SOAP We decided to use SOAP:Lite. (there are...
6
by: xkenneth | last post by:
All, Just a quick question. I want to be able to have a data structure that organizes data (timestamps I'm working with) sequentially, so that i can easily retrieve the first x amount of...
5
by: Henry J. | last post by:
I know this could be a dumb question, I just want to confirm that it is faster to execute inserts, if a timestamp field is set to have a default value, like DEFAULT CURRENT TIMESTAMP, and skip that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...

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.