I'm needing to find the difference between two months in excel. One month is listed as a string, the other I'm calculating by doing
=TEXT(NOW(),"mmmmmmmmmmmm")
I've attempted to get values that I could then use to display a Yes/No based on it being less than. Here is what I've tried, they are on individual lines.
=DATEDIF(M9,G19,"YM")
=IF(M9>G19,Yes,No)
The DATEDIF, I was looking to find number of days, then wrap it in an IF and showing Yes/No depending on positive/negative numbers.
You need to compare them as dates not as strings/text.
Please can you include what the month listed as a string looks like?
If you have December as a string in cell A1 for example, you would convert to date using: =DATEVALUE(1&LEFT(A1,3))
Then get the current date with now(), without turning to text, and compare as dates.
Full thing: =IF(now()>(DATEVALUE(1&LEFT(A1,3))),"Yes","No")
Related
I am trying to find a (reasonably elegant) formula to find out how often a date appears in a list of date ranges.
In my example I have 4 date ranges, defined by a start date (A2:A5) and by an end date (B2:B5). Below I have a list of dates for which I would like to know how often a date appears in any of those 4 ranges. The only solution I came up with was to check for each range if the date is in there. The formula becomes quite lengthy with the number of periods and is not flexible if more periods are added later.
Here the time periods:
And here where I try to retrieve the number of matches given a date:
My formula is here for B11 (yielding 3 given the input of 10/Sep/2021):
=IF(AND($A11>=$A$2,$A11<=$B$2),1,0)+IF(AND($A11>=$A$3,$A11<=$B$3),1,0)+IF(AND($A11>=$A$4,$A11<=$B$4),1,0)+IF(AND($A11>=$A$5,$A11<=$B$5),1,0)
Any ideas appreciated!
Using COUNTIFS:
=COUNTIFS($A$2:$A$5,"<="&A11,$B$2:$B$5,">="&A11)
I'm trying to put multiple rows which contain a date of the month between the first and last day of the month and I want to put them togeather as the first of the month dpeending on which month they are in:
for example; if they have the month of 12 i want to make them the 01/12/2020 if it was november 01/11/2020 and so on...
What i am looking for is to get three or more dates into a single one:
Date
03/12/2020
16/12/2020
27/12/2020
And make it:
Date
01/12/2020
Thanks for any help on how i could go about this, im struggling to find a solution
(I have tried text join and concatenate and neither work)
If you have Excel365 then use-
=DATE(2020,UNIQUE(MONTH(A1:A4)),1)
If you have dates with different years then try below formula.
=DATEVALUE("01-"&UNIQUE(TEXT(A1:A4,"mm-yyyy")))
Pretty unconventional way of doing it but works:
=EOMONTH(EDATE(AVERAGE(A1:A12),-1),0)+1
Where A1:A12 is a range of dates.
You have not specified well whether your dates are strings or actual Excel dates. Nor is it clear to me whether this is an example of a single cell in a larger row. The solution would be different based on the answer to these questions (which I do not have enough reputation to put as comments).
If you already have these values as dates put a new value in an adjacent column. Assuming the existing date value is in cell A1:
=DATE(YEAR(A1), MONTH(A1), 1)
However, if the date value is actually a string you will need to hard code the extraction of the values. Assuming, the are in fixed length strings as your image shows, with dd/mm/yyyy format:
=DATE(RIGHT(A1, 4), MID(A1, 4, 2), 1)
For my Pilots logbook I am trying to be able to make a easy search where you can enter certain criteria and get the amount of landings and time in flight.
For example you could enter the departing airport and it would give you the amount of takeoffs from that airport.
So far I have been able to get the results using the COUNTIFSfunction.
Trying to add a field, where you can enter a year and it would only count the occurrences in that year is giving me a hard time!
The date is in the following format: dd.mm.yyyy. The year to search for would be entered in a cell (yyyy).
Just adding it to the COUNTIFSobviously doesn't work. I know I can get the year out of the date using the YEARfunction, yet I can't figure out a way of including this into the COUNTIF.
Any Ideas?
CODE:
=COUNTIFS(Logbook!F3:F2000,IF(ISBLANK(B30),"*",B30),Logbook!C3:C2000,IF(ISBLANK(C30),"*",C30),Logbook!K3:K2000,IF(ISBLANK(D30),"*",D30),Logbook!L3:L2000,IF(ISBLANK(E30),"*",E30),Logbook!G3:G2000,IF(ISBLANK(F30),"*",F30),Logbook!B2:B2000,B30)
Where B30 is the cell with the year, and B2:B2000 being the cells with the dates.
I also tried to compare by the text (somewhat like RIGHT(Logbook!B2:B2000,4)=B30) but it doesn't do anything but returning a #VALUE error.
Seems like a really good case for PivotTables and slicers... You could even avoid the RIGHT() formula if you format the dates; then you could use the built-in group feature of PivotTables.
I have some dated in this format "09-MAY-13 06.42.46.097127000 PM" and need to convert to this format "2013-05-09T18:42:47.132Z". my goal is to find out which happend earlier. I am not sure how to format these dates.
2013-05-09T18:42:47.132Z 09-MAY-13 06.42.46.097127000 PM
2013-05-08T20:56:55.821Z 06-MAY-13 03.22.09.129443000 PM
2013-05-08T20:51:45.287Z 06-MAY-13 03.03.22.975700000 PM
2013-05-08T20:55:34.719Z 06-MAY-13 10.40.55.924181000 PM
How I can do that??
I originally posted an answer which converted one of your formats to the other. I now see that you need to compare them, so you can convert this format in A2 to date/number values ....
09-MAY-13 06.42.46.097127000 PM
.....with this formula
=SUBSTITUTE(SUBSTITUTE(A2,".",":",1),".",":",1)+0
and this format in A3
2013-05-09T18:42:46.097z
....with this formula
=SUBSTITUTE(SUBSTITUTE(A3,"T"," "),"z","")+0
You can format the results how you like, leave as numbers or format as m/d/yyyy hh:mm:ss.000 or similar. you can now compare easily with a formula like
=B2>B3
or get the smaller or larger with MIN or MAX
If have a value of your original style in cell A1, place the following formula in a different cell:
=DATE((2000+MID(A1,8,2)),MATCH(MID(A1,4,3),{"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"},0),LEFT(A1,2))+TIME(MID(A1,11,2)+IF(RIGHT(A1,2)="PM",12,0),MID(A1,14,2),MID(A1,17,12))
Then, in that target cell, apply the following format:
yyyy-mm-ddThh:mm:ssZ
Please note the following:
This assumes that all of your months are 3 characters (JAN, FEB, MAR). Since your example was "MAY" (already 3 characters), I don't know with certainty how your other months appear. Longer month names complicate the formula a bit. I can help with this if you need it and don't know how to do it.
I couldn't find a way to force Excel to display fractional seconds in the context of such complex date/time formatting, even though your example showed seconds subdivided to the thousandths. Hopefully this isn't a deal-breaker. If it's necessary to display fractional seconds, you may need to handle this with a separate formula to display the result as text, independent of the formula above, which you can use for your calculations of which date came earlier.
To add to Joe's answer...
To get Excel to compare one column to the other you need to do the same sort of manipulation from the first column as the second.
That would look like
=DATE(LEFT(A1,4),MID(A1,6,2),MID(A1,9,2))+TIME(MID(A1,12,2),MID(A1,15,2),MID(A1,18,5))
Once you have a new column for each of these transformations it should be simple to have Excel compare them.
I have 100.000 rows of data in Excel. Some of the fields are dates, but the fields in Excel are as text. I need these fields in number format including both dates AND time (e.g. 21.10.2011 13:10:50). Formatting the cells doesn't work because that doesn't change the datatype. I can pick out the date and time with formulas but not get them in the same cell.
So what I am looking for is the formula to calculate the number representation of a date (the one you see if you format a date as a number).
Have you tried the =DateValue() function?
To include time value, just add the functions together:
=DateValue(A1)+TimeValue(A1)
To accomodate both data scenarios you have, you will want to use this:
datevalue(text(a2,"mm/dd/yyyy"))
That will give you the date number representation for a cell that Excel has in date, or in text datatype.
I was struggling with this for some time and after some help on a post I was able to come up with this formula =(DATEVALUE(LEFT(XX,10)))+(TIMEVALUE(MID(XX,12,5))) where XX is the cell in reference.
I've come across many other forums with people asking the same thing and this, to me, seems to be the simplest answer. What this will do is return text that is copied in from this format 2014/11/20 11:53 EST and turn it in to a Date/Time format so it can be sorted oldest to newest. It works with short date/long date and if you want the time just format the cell to display time and it will show. Hope this helps anyone who goes searching around like I did.
The best solution is using DATE() function and extracting yy, mm, and dd from the string with RIGHT(), MID() and LEFT() functions, the final will be some DATE(LEFT(),MID(),RIGHT()), details here