subtract

Subtract n hours from a DateTime in Ruby

Hello there, I have a Ruby DateTime which gets filled from a form. Additionally I have n hours from the form as well. I'd like to subtract those n hours from the previous DateTime. (To get a time range). DateTime has two methods "-" and "<<" to subtract day and month, but not hour. (API). Any suggestions how I can do that? ...

Quick Java question: Cloning and subtracting sets - does this work?

private HashMap<DataObject, HashSet> AllDataObjects; ... /** Returns all DataObject elements that are NOT in the specified set. */ private DataObject[] invert( HashSet<DataObject> set ) { HashSet<DataObject> keys = (HashSet) AllDataObjects.keySet(); keys = (HashSet) keys.clone(); keys.removeAll( set ); return (DataObj...

Subtract array from another in .net

Is there any easy way to remove the contents of one array from another? ...

Subtracting one row of data from another in SQL

I've been stumped with some SQL where I've got several rows of data, and I want to subtract a row from the previous row and have it repeat all the way down. So here is the table: CREATE TABLE foo ( id, length ) INSERT INTO foo (id,length) VALUES(1,1090) INSERT INTO foo (id,length) VALUES(2,888) INSERT INTO foo (id,length) VALUES(3...

MySQL how to remove records in a table that are in another table

I have table A with close to 15000 entries. I have a second table B with 7900 entries with a common field with table A. I need to extract into a third temporary tableC all entries from table A except the ones that also appear in table B. Simple as it may sound, i havent found a way to do it. The closest i got was this: INSERT INTO tab...

What method is needed to have the "-" ( subtract ) method working with Ruby arrays?

If I have two arrays a and b, what method should the object contained have to override so the subtract method - works properly? Is it enough with eql? EDIT I'm adding more detail to my question. I have this class defined: class Instance attr_reader :id, :desc def initialize( id , desc ) @id = id.strip @d...

javascript subtract(-) keycode

ok, i need my code to check if minus/subtract/- was pressed, if it was pressed i want an alert box to pop. i tried with both 109 and 189 key codes but i still don't get the desired result. although i press "-" i don't get that alert box ...

JQuery: Detecting a Browser Resize

I am using this script from snipplr, How would I set it so the container div is 100px less than the newWindowHeight height, like -100 or something. <script type="text/javascript" charset="utf-8"> $(document).ready(function(){ //If the User resizes the window, adjust the #container height $(window).bind("resize", resizeWindow); function...

Subtracting long numbers in javascript

Why is q == 0 in the following script? <script> var start = 1234567890123456789; var end = 1234567890123456799; var q = end - start; alert(q); </script> I would think the result should be 10. What is the correct way to subtract these two numbers? ...

How to subtract a month from Date object?

How do I subtract a month from a date object in VB.NET? I have tried: Today.AddMonths(-1) However, given that Today is 01-Jan-2010, the result I get is 01-Dec-2010. The answer I want is 01-Dec-2009. Is there a convenient way of doing this within the .NET framework? ...

Algorithm to add or subtract days from a date?

Hi, I'm trying to write a Date class in an attempt to learn C++. I'm trying to find an algorithm to add or subtract days to a date, where Day starts from 1 and Month starts from 1. It's proving to be very complex, and google doesn't turn up much, Does anyone know of an algorithm which does this? ...

Subtract 1 year from datetime

I have seen a lot of info on how to subtract one datetime from the other and how to add years on to a datetime. but the following is giving me a headache.... When a user inserts a record a hidden field called subdate with a value of datetime.now is added to the db. I then need to have an 'old records' page that lists all the entries th...

Subtract time on specific lines using php

Using php I'd like to subtract/minus two times; each time within a separate document and thereafter have php write the result (Result after subtracting the two times) within another single text document or within a html document with no HTML tags, just text. The two times subtracted will determine how long a certain player has played the...

Finding date by subtracting X number of days from a particular date in C

I am looking for a sample in C to get the result date when input of number of days and a date is given . inputs are date_t end_date, int days=7 is given I should get a date_t start_date which is 7 days before than end_date value ...

Android Java : How to subtract two times ???

I use some kind of stopwatch in my project and I have start time ex: 18:40:10 h stop time ex: 19:05:15 h I need a result from those two values like final time = stop - start I found some examples but they all are very confusing . Is there any simple solution ? ...

PHP Subtract First Character of String

Hello, I know this is simple, and I've done it before, but I've forgotten how to do it. How might I, in php, subtract the first letter of a string? For example: FOOBAR would become OOBAR I think its something like $string[-1]; Thanks, Christian Stewart ...

Subtract two time values in ms sql server 2008

Hai all, How to subtract two time values in sql server 2008.I am using time variables in stored procedure. please help ...

How to represent / Modify 3d solids

In my program I have some cubes (simple, xyz location, xyz size). I want bo be able to take one of these cubes and 'Subtract' another cube from it. So my question, what is a good generic data structure to represent the resulting 3d object, and what kind of algorithm is used to subtract a 3d solid from another? ...