Convert String To Time Duration In Excel [duplicate] - excel

This question already has answers here:
Converting Time Formats in Excel
(2 answers)
Closed 6 years ago.
May I know the way to convert "1 h 49 m 57 s" to 1:49:57 in Excel.
Thanks in advance

You can use this formula to replace letters to colons then convert text to value:
=VALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A5," h ",":")," m ",":")," s",""))
After inserting the formula set the cell's number format to "time".

Related

Having hard time figuring out a formula in Excel for trimming symbols and moving to a next row [duplicate]

This question already has answers here:
Excel macro -Split comma separated entries to new rows [duplicate]
(4 answers)
Split comma separated entries to new rows [closed]
(2 answers)
Closed 1 year ago.
Before
1
2
3
4
11111-CZ20-00995
NiceFoodsCo
Installment
7789231;7652137
After
1
2
3
4
11111-CZ20-00995
NiceFoodsCo
Installment
7789231
11111-CZ20-00995
NiceFoodsCo
Installment
7652137
Basically I need it to remove the ';' and then move to next row with same data
Any advice would be appreciated, already tried VLookup, XLookup, Trim, Row, Substitute (and combination of all these)

How to a convert a string in this format "20180101" into a date value like 01/01/2018 in Excel? [duplicate]

This question already has answers here:
Changing YYYYMMDD to MM/DD/YYYY
(5 answers)
Closed 4 years ago.
What formula can I use to transform the string into a date value that will appear as 01/01/2018?
If you are trying to do this from a formula into another cell, and not in situ (For which, use "Text to Columns" as per Jeeped's answer), you can either combine DATE and MID, or use REPLACE and convert with +0 or DATEVALUE:
=DATE(MID(A1,1,4), MID(A1,5,2), MID(A1,7,2))
OR
=REPLACE(REPLACE(A1,7,0,"-"),5,0,"-")+0
OR
=DATEVALUE(REPLACE(REPLACE(A1,7,0,"-"),5,0,"-"))
(Where A1 is the date to convert)
The first formula just cuts the number up into 2018 01 01 and uses those as Year, Month and Day. The second 2 work by first Inserting (i.e. REPLACE 0 characters) a hyphen at position 7 ("201801-01") and then at position 5 ("2018-01-01") and converting the string back to a number/date.
Use Data, TextToColumns, Fixed width, Date: YMD, Finish. Possibly Date: YDM depending on your string date format (you provided an ambiguous example).
use the code below
=RIGHT((text),2)&"/"&MID((text),5,2)&"/"&LEFT((text),4)
Use the DATEVALUE() function which takes as input a text format. Not that if your output cell is not in Date format you will see a simple int insteade of the expected 1/1/2016.
I refer you to the DATEVALUE function documentation for more insight on the input format and so on

Cannot convert string to date in R [duplicate]

This question already has answers here:
What are the "standard unambiguous date" formats for string-to-date conversion in R?
(8 answers)
Closed 9 years ago.
I need your help to figure out the following problem-
I am trying to convert a date column from string to actual date format. I have tried using as.Date
However, it is showing an error message:
Error in charToDate(x) :
character string is not in a standard unambiguous format
the date column I have in csv file is like this:
Date
03/17/2003
05/31/2003
09/06/2003
10/18/2003
07/15/2003
09/19/2003
The problem is some of the dates are in string and some are in actual date format. I have tried to format it from excel - didn't work
Tried to copy and paste it to notepad and then import it again - didn't work either.
You need to learn about the help system in R. One brief look at help(as.Date) may have told you about the format argument:
R> dt <- c("03/17/2003", "05/31/2003", "09/06/2003")
R> as.Date(dt, "%m/%d/%Y")
[1] "2003-03-17" "2003-05-31" "2003-09-06"
R>
Edit: These days we also have a helper package that does the format-finding for you:
> dt <- c("03/17/2003", "05/31/2003", "09/06/2003")
> anytime::anydate(dt)
[1] "2003-03-17" "2003-05-31" "2003-09-06"
>
This works for datetimes (using anytime()) and dates.

python3: how do i format 2 as 02 [duplicate]

This question already has answers here:
Display number with leading zeros [duplicate]
(19 answers)
Closed 8 years ago.
Apologies if this is a repeat question but,
what formatting commands do i need to use if I want a single digit number to be displayed with a zero in front?
i.e. the number '2' would be displayed as '02'.
[But, I do not want any value above 10 to have extra zeros in front]
cheers
You can use this syntax:
>>> "{:0>2}".format(2)
'02'
>>> "{:0>2}".format(98)
'98'
>>> "{:x>4}".format(2)
'xxx2'
More info: Common string operations
Try:
if 0 < num < 10:
return "0" + str(single_digit)

formatting character arrays [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Counting values by day/hour with timeseries in MATLAB
This is an elementary question, but I cannot find it:
I have a 3000x25 character array:
2000-01-01T00:01:01+00:00
2000-01-01T00:01:02+00:00
2000-01-01T00:01:03+00:00
2000-01-01T00:01:04+00:00
These are obviously times. I want to reformat the array to be a 3000x1 array. How can I redefine each row to be one entry in an array?
(Again, this is simple, I'm sorry)
Other than converting to serial date numbers as other have shown, I think you simply wanted to convert to cell array of strings:
A = cellstr(c)
where c is the 3000x25 matrix of characters.
You need to specify a format for the array and feed it to datenum, like this:
>> d = datenum(c,'YYYY-MM-DDTHH:mm:ss')
d =
1.0e+005 *
7.3487
7.3487
7.3487
7.3487
The times are now stored as datenums, i.e. as floating point numbers representing the number of days elapsed since the start of the Matlab epoch. If you want to convert these to numbers representing the fraction of the day elapsed, you can do
>> t = d - fix(d);
and if you want the number of seconds since midnight, you can do
>> t = 86400 * (d - fix(d));
t =
61.0000
62.0000
63.0000
64.0000

Resources