Excel Offset Subtraction Inside Cells? - excel

I have thousands of rows of these two columns worth of data that looks exactly to this. The date and time of an event is listed inside a single cell. I need to be able to subtract the time in one cell from the other, but I'm not sure exactly how to go about doing this.
For instance, I would need to somehow pull 4:00am and subtract the difference of 6:00am - leaving me an answer of 2 hours. Thank you ahead of time!
Nov 25, 2016 4:00:00 AM Nov 25, 2016 6:00:00 AM
Nov 25, 2016 4:00:00 AM Nov 25, 2016 6:00:00 AM
Nov 25, 2016 4:00:00 AM Nov 25, 2016 5:15:00 AM
Nov 25, 2016 4:00:00 AM Nov 25, 2016 6:00:00 AM
Nov 25, 2016 4:00:00 AM Nov 25, 2016 6:00:00 AM

In C1:
=24*(B1-A1)
and fill down.
Dates in Excel are managed such that subtracting A1 from B1 gives a fraction of a day, so multiply by 24 to get number of hours.

Related

How to calculate days since 1900 generated by excel date?

Excel is converting the date 03/11/2021 to value 44535, which seems to be days since 1900. I´m trying to figure out a way to calculate this using my own golang libs. Does anyone have this kind of problem?
Thank you a lot for your help
A not so fency workaround for this problem would be addDays
d := time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC)
fmt.Println(d) // 1900-01-01 00:00:00 +0000 UTC
d2 := d.AddDate(0, 0, 44503)
fmt.Println(d2) // 2021-11-05 00:00:00 +0000 UTC
Would print: 05/11/2021 witch is 2 days more than what we desire.
Here we can see the same using JavaScript:
date = new Date(1900, 0, 1)
// Mon Jan 01 1900 00:00:00 GMT-0338 (Amazon Standard Time)
date.setDate(date.getDate() + 44503)
// Fri Nov 05 2021 00:00:00 GMT-0400 (Amazon Standard Time)
After some research about this 2 days I found this in a comment by #chux-reinstate-monica:
If you choose to use MS Excel to check your work note 2 things: 1) Jan 1, 1900 is day 1 (not the number of days since Jan 1, 1900) and 2) according to Excel Feb 29, 1900 exists(a bug in their code they refuse to fix.)
So we can substract 2 days from that to have: 03/11/2021.

Is it possible to convert date/time in Excel such as "Mon Nov 11 2019 22:12:22"?

Is it possible to convert a date/time in Excel such as Mon Nov 11 2019 22:12:22 UTC time to and EST date/time value? Essentially subtract 5 hours from it? Some of the formulas I've been playing with are:
=C2-5/24
=(SUBSTITUTE(LEFT(A1,27),"T"," "))+(MID(A1,28,3)/24)

Cron expression that runs for every 2 years

I need to run a particular script starting from Jan 1st of 2019 at 12 AM and next it should run on Jan 1st 2021 at 12 AM, then on Jan 1st 2023 at 12 AM and soon.
You can create and/or check the cron expression format with http://www.cronmaker.com/
0 0 0 1 1 ? 2019/2
This should work. It will run the task on
1. Tuesday, January 1, 2019 12:00 AM
2. Friday, January 1, 2021 12:00 AM
3. Sunday, January 1, 2023 12:00 AM
4. Wednesday, January 1, 2025 12:00 AM
5. Friday, January 1, 2027 12:00 AM

Excel:Next year period

How to get next year period based on current month and year, for example:
Jan 2014 - Dec 2014
Feb 2014 - Jan 2015
Mar 2014 - Feb 2015
Apr 2014 - Mar 2015
May 2014 - Apr 2015
Jun 2014 - May 2015
Jul 2014 - Jun 2015
Aug 2014 - Jul 2015
Sep 2014 - Aug 2015
Oct 2014 - Sep 2015
Nov 2014 - Oct 2015
Dec 2014 - Nov 2015
Next period
Jan 2015 - Dec 2015
Feb 2015 - Jan 2016
etc.
I have tried with the following formula:
=UPPER(TEXT(NOW();"MMM")) &" "& TEXT(NOW();"YY")-1
It works fine for Jan 2014 but can't figure out how to get Dec 2014; Feb 2014 - Jan 2015 and so on?
I think you need the EOMonth formula.
=EOMONTH(NOW(),-13) +1 and =EOMONTH(NOW(),-2) +1 should give give you JAN 2014 to DEC 2014
from the MS Excel documentation
Microsoft Excel stores dates as sequential serial numbers so they can
be used in calculations. By default, January 1, 1900 is serial number
1, and January 1, 2008 is serial number 39448 because it is 39,448
days after January 1, 1900.
To get the text formatting you are after, I would suggest that you stick with formatting the cell/column as #Makyen has suggested. Having said that this is the formula that you can use to format the text.
=UPPER(TEXT(EOMONTH(NOW(),-13) +1, "MMM YY"))
Assuming that the date (as a date serial number) for which you desire to find the year period is in cell A1, the following should provide the next year period starting from that day:
=EOMONTH(A1,11) +DAY(A1) -1
Examples:
Input Output
1/18/2014 1/17/2015
2/18/2014 2/17/2015
3/18/2014 3/17/2015
4/18/2014 4/17/2015
5/18/2014 5/17/2015
6/18/2014 6/17/2015
7/18/2014 7/17/2015
8/18/2014 8/17/2015
9/18/2014 9/17/2015
10/18/2014 10/17/2015
11/18/2014 11/17/2015
12/18/2014 12/17/2015
1/18/2015 1/17/2016
2/18/2015 2/17/2016
3/18/2015 3/17/2016
4/18/2015 4/17/2016
5/18/2015 5/17/2016
6/18/2015 6/17/2016
7/18/2015 7/17/2016
8/18/2015 8/17/2016
9/18/2015 9/17/2016
10/18/2015 10/17/2016
11/18/2015 11/17/2016
12/18/2015 12/17/2016
1/18/2016 1/17/2017
If you want the year period to start from the current day:
=EOMONTH(NOW(),11) + DAY(NOW()) -1
If you want the year period to start from the first day of the current month:
=EOMONTH(EOMONTH(NOW(),-1) + 1,11)
or
=EOMONTH(NOW() - DAY(NOW()) + 1,11)
The EOMONTH() function:
EOMONTH(start_date,months)
Returns the serial number for the last day of the month that is the
indicated number of months before or after start_date. Use EOMONTH to
calculate maturity dates or due dates that fall on the last day of the
month.
If this function is not available, and returns the #NAME? error,
install and load the Analysis ToolPak add-in.

Problems with converting text to date (YYYY-MM-DD) in Excel (Mac)

I have been able to convert this date to YYYY-MM-DD HH:mm but not anymore. What can I do to convert this date.
Sep 15, 2014 9:30:32 AM
You need to know that I'm using Swedish keyboard, date and region.
Example:
Order # Purchased On
100026881 Sep 15, 2014 9:30:32 AM
100026880 Sep 15, 2014 9:10:56 AM
100026879 Sep 15, 2014 9:09:10 AM
100026878 Sep 15, 2014 9:03:27 AM
100026877 Sep 15, 2014 8:57:02 AM
100026876 Sep 15, 2014 8:38:37 AM
100026875 Sep 15, 2014 6:54:29 AM
100026874 Sep 15, 2014 5:03:23 AM
100026873 Sep 15, 2014 2:45:50 AM
100026872 Sep 15, 2014 1:42:26 AM
100026871 Sep 14, 2014 11:20:31 PM
100026870 Sep 14, 2014 11:16:29 PM
100026869 Sep 14, 2014 11:11:15 PM
100026868 Sep 14, 2014 11:10:06 PM
100026867 Sep 14, 2014 10:42:56 PM
100026866 Sep 14, 2014 10:41:22 PM
100026865 Sep 14, 2014 10:36:43 PM
100026863 Sep 14, 2014 10:26:13 PM
Formatting a date in Excel 2011 for Mac
You have at least three different ways to apply a date format. Perhaps the fastest is to select a cell or cell range, and then click the Home tab of the Ribbon. In the Number group, click the pop-up button under the Number group title and choose Date to display the date as m/d/yy, where m represents the month's number, d represents the day number, and yy represents a two-digit year.
Excel has many more built-in date formats, which you can apply by displaying the Format Cells dialog by pressing Command-1 and then clicking the Number tab. You can also display the Number tab of the Format Cells dialog by clicking the Home tab on the Ribbon. Then click the pop-up button under the Number group title and choose Custom from the pop-up menu.
When the Format Cells dialog displays, select the Date category. Choose a Type from the list. Choosing a different Location (language) or Calendar type changes the date types offered.
I hope this may helps..
This should be a comment since I have neither Swedish settings not a Mac but I am suggesting a lookup table:
+-----+----+
| Jan | 1 |
| Feb | 2 |
| Mar | 3 |
| Apr | 4 |
| May | 5 |
| Jun | 6 |
| Jul | 7 |
| Aug | 8 |
| Sep | 9 |
| Oct | 10 |
| Nov | 11 |
| Dec | 12 |
+-----+----+
say named Marray, along with:
=TEXT(DATE(MID(B2,9,4),VLOOKUP(LEFT(B2,3),Marray,2,0),MID(B2,5,2))+VALUE(TRIM(RIGHT(B2,11))),"[$-41D]mmmm dd, yyyy h:mm:ss AM/PM")
in C2 and copied down to suit (assuming Sep 15, 2014 9:30:32 AM is in B2).
For single digit dates, perhaps:
=TEXT(DATE(TRIM(MID(B2,8,5)),VLOOKUP(LEFT(B2,3),Marray,2,0),SUBSTITUTE(TRIM(MID(B2,4,3)),",",""))+VALUE(TRIM(RIGHT(B2,11))),"[$-41D]mmmm dd, yyyy h:mm:ss AM/PM")
For me (Windows, Excel 2013, English!) this returns:
It may be necessary to replace all ,s with ;, except one inside SUBSTITUTE.
I think that Jeeped might be close to the problem.
My guess is that now the data may have been pasted as text, instead of recognizing the date. (pnuts had an answer but it's a lot more work than using the builtin Excel functions.)
If the dates are in their own column, like:
Sep 15, 2014 9:30:32 AM
Sep 15, 2014 9:10:56 AM
Sep 15, 2014 9:09:10 AM
etc
Then you might have to get Excel to parse the text dates.
If the date text is in B2, put this formula in another cell (say B3):
=DATEVALUE(B2) + TIMEVALUE(B2)
Then you can format with this custom formatting string: yyyy-mm-dd h:mm:ss AM/PM
Which will give you:
2014-09-15 9:30:32 AM
2014-09-15 9:10:56 AM
2014-09-15 9:09:10 AM
etc.
Hope this helps.

Resources