How to add month and day to a numbered year in excel? - excel

I have a column of years, 2000, 1990 > 900 (0900) > 1876 etc.... However I needed to have it in a date format e.g. 01/01/2000, 01/01/900 (01/01/0900). I can't work out how to do this. I can only see formulas which add days and months which are already in the format I would like. I only need it as 01/01 to input to QGIS as a csv file.

Dates are represented in Excel by real numbers. The integer part (to the left of the decimal place) is the number of days since 12/30/1899. The fractional part (to the right of the decimal place) is the fraction of the day. .5 = noon, .75 = 6pm, etc. How these numbers appear in the worksheet depends on the number format of the cell. So if your cell value is 36526 (or 1/1/2000) and the number format is "mm/dd/yyyy" you will see '01/01/2000' in the cell. If the number format is "mm/dd", you will see '01/01' in the cell.
I don't understand what you mean by "I only need it as 01/01 to input to QGIS as a csv file" but if you show me some code, and explain how the results you're getting differ from the results you want, I can probably help get you there.

Related

Extract the hour from the h" hour(s) and "m" minute(s)" in excel

I have the list of data that showing the Hours and the Minutes that I extract from the system. I need to be extract the hours.
As example below, column B first row, the Hours would be 64 and the minutes would be 46.
But when I used the formula =Hour , its turn up the different value since its actually decimal number.
Cannot use left() , it will give the actual decimal number.
Updated:
We tried the #harun24HR 's but cannot readable the value.
But if you noticed, if i copy and paste the value is different. thats why the search not applicable.
4th Update:
To Solar Mike, I have tried the formula given from the thread the i think the value not readable
It's a time value which Excel stores as calculated value based on 24 hours = 1.
To retrieve the hours only you can use:
=INT(A2*24)
To retrieve the minutes only you can use:
=(A1-(INT(A1*24)/24))*24*60
Your time value is already a number in time format so you just need it to change it to decimal system. Dates and time values are numbers. Even if you see it as 30/09/2019 or 12:00:00, actually, for Excel, both cases are numbers.
First date Excel can recognize properly is 01/01/1900 which integer numeric value is 1. Number 2 would be 02/01/1900 and so on. Actually, today is 44659.
Now, about your data, you posted this screenshoot:
So the value is numeric, not text/string. In Excel, what you see is not always what you have. Probably that column has been formatted using custom mask. My fake data is like this:
The numeric value is 02/01/1900 16:46:36 (or 02/01/1900 4:46:36 PM it depends on your regional settings) but I've applied a custom format like this:
[hh]" hours" mm " minutes"
So what I have is a number but what I see is a text!
We have to work with the number (to be honest, ist's easier to work with numbers), so to extract the total hours, minutes and seconds.
Formula in B1: =INT(A1*24) total hours
Formula in C1: =INT(A1*24*60-B1*60) total minutes
Formula in D1: =A1*24*60*60-B1*60*60-C1*60 total seconds
This should guide you on whatever are you trying to achieve.
From your current sample data you try-
For hour =LEFT(A2,SEARCH(" ",A2)-1)
For minutes =RIGHT(SUBSTITUTE(A2," minutes",""),2)

Convert Modified Julian Date to UTC Date in Excel

I am looking for a formula where I can put a 5 digit Modified Julian Date and have it convert it to today's date for me.
I did it in a way where I have a separate sheet with a table but although it works, I am looking for a way without the need of a separate table. Here is some information:
00000 should translate to 11-17-1858
58890 should translate to 02-11-2020
Every time the number goes up 1, it should go up 1 day. This needs to have leap years in consideration as well. Any help will be appreciated.
Here is a website that currently does the conversions:
http://www.csgnetwork.com/julianmodifdateconv.html
This has to be done without macros, literally need it in formula format.
Just subtract 15018 and format the result as a date.
Why 15018 and not 15020?
In Excel, 1-Jan-1900 value is 1
In your date scheme 15020 = 1-Jan-1900
But, if you had the number 15020 to convert and subtracted 15020 it would --> 0, not the desired 1.
Therefore we reduce the 15020 by 1 to 15019.
Next, there is a deliberate "bug" in Excel, widely discussed both on SO and the internet, whereby the year 1900 is erroneously classified as a leap year.
So for any date equivalent that is after 28-Feb-1900, we have to subtract an extra 1.
If you might be dealing with dates between 1/1/1900 and 2/28/1900 you will need to modify the formula to take that into account.

Converting date from general type to date, 9/29/1986 0:00:00 to dd/MM/YYYY CSV file

i have hit wall after trying INT, TIMEVALUE and all other date formatting on the dates in CSV file.
I was able to change few dates using INT and then change the date format but few dates (highlighted in yellow) i am not able to convert to date format. Originally it is string, which i tried changing to Number and Date type before applying formulas but still its not getting formatted correctly.
i have tried MID/LEFT etc. to extract part of it but when joining these parts using "" & "" converts to text and converting it to date resulted in long ##### output, did tried excel advance option ticking Use 1904 date system.
Any help in right direction is much appreciated. i have not found any duplicate question similar to my format, closest i found didnt have time stamp so that formula didnt work either.
Take a look at your date format. The first digit is either 1 or 2 characters and you need to take that variation into account. the nice thing is based on your data that the days is always 2 digits. this simplifies things a little.
Lets start with the basics and assume your first string of a date is in A2. Let us start simply by striping out the numbers from the text one segment at at time while being generic about the position and number of character. So in order to pull out the number for the month, use the following formula:
=LEFT(A2,FIND("/",A2)-1)
Find will look for the position of the / character in the string and return its number. in this case it should be 2. This means its a single digit month. So we only need to pull 1 digit. In the general sense 1 less than the position of the /.
The next task will be to pull the digits for the day. We can do that using a similar formula. This time lets use MID instead of left. In order to for MID to work, we need to define the starting point. This time the general case of the start point will be the first character after the first /. The other nice part about this is we know the number of characters to pull will always be 2. As such you can use the following formula to pull the month:
=MID(A2,FIND("/",A2)+1,2)
(note if your day digits were not consistently 2 then you would have to measure the number of characters between the two / characters and replace the 2 in the formula with you calculation)
In order to pull the year the process is basically the same as for the month with some minor tweaks. The resulting formula I am suggesting is:
=MID(A2,FIND("/",A2,4)+1,4)
Now the reason I used 4 as the starting position for the find is to make the formula work for the case where days could be a single digit. It the closest the second / can be to the start.
now that you have all that you need to combine it together to make the date. This is where the DATE formula comes into play. It works in the following format: DATE(Year, Month, Day). So now we simply grab each of the individual formula and build the DATE formula which should wind up looking like the following:
=DATE(MID(A2,FIND("/",A2,4)+1,4),LEFT(A2,FIND("/",A2)-1),MID(A2,FIND("/",A2)+1,2))
if you get a date that is just bunch of number format the cell to display the date in the format of your choosing.

Excel Date calculation

Excel calculating date in two different ways. When adding two date's (even no of date's), it displaying serial date. But when i add three date's (odd no of date's), it displaying in normal date. How excel date calculation working...
Dates in Excel are stored as numbers - numeric value of "1.000" equals 01-Jan-1900 00:00 - with fractions representing the time of the day (e.g. 1/24 = 1 hour)
Formatting cells as "Date" just changes the representation
You normally do not "add dates", you add/subtract a number of days (or fractions thereof) to/from a date, either directly or by use of Excel functions. So I cannot imagine in which context the above calculation could make any sense.
It does make sense to substract 2 dates to get the # of days in between - do not forget to set the format of the result to "General" as the default is to keep the date format, and add 1 to get a day count containing both cornering dates (e.g. =DEnd-DStart+1)
You can though add times and present them with overflowing seconds, minutes or hours by using custom formats like [s], [m]:ss, [h]:mm:ss etc.

Excel 2007: How to display mm:ss format not as a DateTime (e.g. 73:07)?

I need to create and Excel table that computes daily training times. each row has the following fields: Date, Distance, Time and Minutes/Km. My main problem is that I want to display the Time in format of mm:ss. For example: 24 min and 3 sec should be 24:03, but "Excel" turns it to 00:03:00 (3 min after midnight). I've tried setting up "special formatting" but still "Excel insists" on formatting the hours. More over, training may exceed 60 minutes and I still want it only as mm:ss
My second question is after I'm done with the formatting issue, what is the simple way to compute Time/Distance?
enter the values as 0:mm:ss and format as [m]:ss
as this is now in the mins & seconds, simple arithmetic will allow you to calculate your statistics
Excel shows 24:03 as 3 minutes when you format it as time, because 24:03 is the same as 12:03 AM (in military time).
Use General Format to Add Times
Instead of trying to format as Time, use the General Format and the following formula:
=number of minutes + (number of seconds / 60)
Ex: for 24 minutes and 3 seconds:
=24+3/60
This will give you a value of 24.05.
Do this for each time period. Let's say you enter this formula in cells A1 and A2. Then, to get the total sum of elapsed time, use this formula in cell A3:
=INT(A1+A2)+MOD(A1+A2,1)
Convert back to minutes and seconds
If you put =24+3/60 into each cell, you will have a value of 48.1 in cell A3.
Now you need to convert this back to minutes and seconds. Use the following formula in cell A4:
=MOD(A3,1)*60
This takes the decimal portion and multiples it by 60. Remember, we divided by 60 in the beginning, so to convert it back to seconds we need to multiply.
You could have also done this separately, i.e. in cell A3 use this formula:
=INT(A1+A2)
and this formula in cell A4:
=MOD(A1+A2,1)*60
Here's a screenshot showing the final formulas:
To make life easier when entering multiple dates/times it is possible to use a custom format to remove the need to enter the colon, and the leading "hour" 0. This however requires a second field for the numerical date to be stored, as the displayed date from the custom format is in base 10.
Displaying a number as a time (no need to enter colons, but no time conversion)
For displaying the times on the sheet, and for entering them without having to type the colon set the cell format to custom and use:
0/:00
Then enter your time. For example, if you wanted to enter 62:30, then you would simply type 6230 and your custom format would visually insert a colon 2 decimal points from the right.
If you only need to display the times, stop here.
Converting number to time
If you need to be able to calculate with the times, you will need to convert them from base 10 into the time format.
This can be done with the following formula (change A2 to the relevant cell reference):
=TIME(0,TRUNC(A2/100),MOD(A2,100))
=TIME starts the number to time conversion
We don't need hours, so enter 0, at the beginning of the formula, as the format is always hh,mm,ss (to display hours and minutes instead of minutes and seconds, place the 0 at the end of the formula).
For the minutes, TRUNC(A2/100), discards the rightmost 2 digits.
For the seconds, MOD(A2,100) keeps the rightmost 2 digits and discards everything to the left.
The above formula was found and adapted from this article:
PC Mag.com - Easy Date and Time Entry in Excel
Alternatively, you could skip the 0/:00 custom formatting, and just enter your time in a cell to be referenced of the edge of the visible workspace or on another sheet as you would for the custom formatting (ie: 6230 for 62:30)
Then change the display format of the cells with the formula to [m]:ss as #Sean Chessire suggested.
Here is a screen shot to show what I mean.
If you are using hand inputted data, you can enter your data as mm:ss,0 or mm:ss.0 depending on your language/region selection instead of 00:mm:ss.
You need to specify your cell format as [m]:ss if you like to see all minutes seconds format instead of hours minutes seconds format.
as text:
=CONCATENATE(TEXT(cell;"d");" days ";TEXT(cell;"t");" hours ";MID(TEXT(cell;"hh:mm:ss");4;2);" minutes ";TEXT(cell;"s");" seconds")
5.In the Format Cells box, click Custom in the Category list.
6.In the Type box, at the top of the list of formats, type [h]:mm;# and then click OK. (That’s a colon after [h], and a semicolon after mm.)
YOu can then add hours. The format will be in the Type list the next time you need it.
From MS, works well.
http://office.microsoft.com/en-us/excel-help/add-or-subtract-time-HA102809662.aspx
One convenient trick to entering elapsed times into Excel is to have two zeros and a colon before the number of minutes, details follow. For copy and paste operations into Excel without have to worry about formatting at all one can use the format 00:XX:XX where XX are two digits totaling < 60. In that case, Excel will echo 0:XX:XX in the cell contents displayed and store the data as 12:XX:XX AM. If one pastes data in a 00:XXX:XX format into Excel, or 00:XX:XX where either XX > 59 this will be converted into a fraction of a day.
For example, 00:121:12 becomes 0.0841666666666667, which if multiplied by the number of seconds in a day, 86,400, becomes 7272 s. Next, 00:21:12 would by default show 0:21:12 stored as 12:21:12 AM. Finally, 00:21:60 becomes 0.0152777777777778, also a fraction of a day.
This suggestion is made merely to avoid having to worry about specific formatting in Excel, and letting the program worry about it. Note, for Excel data internally formatted as 12:XX:XX AM one can only use certain Excel commands, for example, one can take an average. However, subtraction will only work when the result is a positive number. Such that converting times into seconds, fractions of a day, or other real number is suggested for access to more complete arithmetic operation coverage.
For example, if one has a column of mixed time formats, or times that are negative and will not display, if one changes the number formatting to General, all the times will be converted to fractions of a day.

Resources