I'm trying to convert a date into a week number, which should be simple, only it's giving back value. Instead of the week number, it says 16/01/1900 00:00:00.
I used =ISOWEEKNUM(C2) and =WEEKNUM(C2, 2) and I tried it without time and in different date formats as well.
Does somebody know how to fix this issue?
Issue is found, the cells of the week numbers had a date format, so I had to convert it into plain text. It works now!
Related
I am trying to figure out how to add +8hours to a schedule formatted with a text in front and a dash in between the hours. Please see example below:
Training 01:45AM - 02:45AM
Convert that time to +8 hours.
Training 09:45AM - 10:45AM.
I just cant seem to figure out the best formula to use in this scenario.
Supposing the raw data string from your post were in A2, this should work:
=REGEXREPLACE(REGEXREPLACE(A2,REGEXEXTRACT(A2,"(\d.+M) -"),TEXT(VALUE(REGEXEXTRACT(A2,"(\d.+M) -"))+TIME(8,0,0),"hh:mmAM/PM")),REGEXEXTRACT(A2,"- (\d.+M)"),TEXT(VALUE(REGEXEXTRACT(A2,"- (\d.+M)"))+TIME(8,0,0),"hh:mmAM/PM"))
In short, this formula uses REGEXEXTRACT to pull each time from the string, convert it to a value, add eight hours, convert it back to TEXT and finally reinsert that transformed substring back into the original string with REGEXREPLACE. Because this happens twice, you'll see two such setups, one wrapped within the other.
I'm reading currency values from a website and I'd like to do some calculations with these numbers. They come in this format:
$7,821.24
Here's an example file:
https://docs.google.com/spreadsheets/d/1vHEH_m16KXcDh7hY_BVG9lur1huFjWOnx5bWtgrdGdA/edit?usp=sharing
Now for some reason neither VALUE() and TO_PURE_NUMBER work for me (Can't parse to numberic value, telling me it's a text value).
My guess is that the comma and the $-sign confuse the formula, is there anything I can do to format this correctly? The dollar sign always appears in the values but the comma only appears separating thousands of values.
I just started using Sheets for this so I absolutely have no clue. Would really appreciate if someone could help me out.
Thanks for your time!
Issue:
It's a locale problem. The value coming from IMPORTXML is formatted as in United States locale, so your spreadsheet (which uses a different format) cannot convert it.
Solution #1. Changing locale:
If the spreadsheet locale is changed to United States or others with the same format (via selecting File > Spreadsheet settings and setting the mentioned locale), the retrieved value will be a number, and you can work with it without using any other formula.
Solution #2. Formula:
If changing the locale is not an option, one possible way to convert the value to a valid number in your locale is the following formula:
=SUBSTITUTE(SUBSTITUTE(RIGHT(A2;LEN(A2)-1);",";"");".";",")
Changing locale didn't work in my case. But I was able to split the number which google sheet isn't detecting as a real number. So split it with "," and "." and any currency sign you may have, and then combine individual values for desired output
I've got a lot of "duration" values - basically a race duration - in a format m:ss.millis [4:03.810 for example].
Currently GS handles it as text, but I would like to use those values for comparison and create some statistics.
Is this possible? I have read this: How to format a duration as HH:mm in the new Google sheets but even though I have created a custom formats like:
or
but neither with one nor with another I cannot use those values for calculations. GS always complains about the values beeing stored as text.
I guess I'm just doing something wrong, but I definitely need to be able to provide values in this format and be able to use them in calculations.
How can I do that?
I regret that Duration seems to be a useless abomination and Sheets appears to offer no relatively easy way to convert text representation to values. Pending a better answer I suggest you convert all your durations as below:
=(left(A1,find(":",A1)-1)+right(A1,6)/60)/1440
format as Number:
mm:ss.000
and then apply your formulae.
(Change , to ; if required by your locale.)
A shorter formula might be used to cajole TIMEVALUE to work by including an hour value of 0:
=TIMEVALUE("00:"&A1)
A happy coincidence brought me back here because only very recently have I found that Google Sheets does offer a way to convert Text to Number (or I was having another aberration when I claimed otherwise). However, this still seems not to apply to Duration. Maybe there is yet hope though.
I have a strange problem with parsing date string. I have a date formatter with format:
yyyy-MM-dd HH:mm:ss.SSSSSSZZ
and date string:
2012-11-09 10:47:01.999804+01
dateFromString method returns nil, but when I change date string to ie:
2012-11-09 10:47:01.989804+01
it works... Does anyone has idea why there is such limit for microseconds value and how can I properly parse dates like the one above?
I could parse that with regex and cut whole SSSSSS part, but generally sometimes I will need to compare dates so they would not be matching and it will cause more problems.
I had no end of niggly issues doing this, finally got it to work but stripped the point seconds off and used the format as follows
#define DATEFORMATSTRINGTIMEZONE #"yyyy-MM-dd HH:mm ZZZ"
a bit like you say. I have to admit a bit more into the project I realized this was a very difficult method of sharing dates and instead adopted epoch time which has saved all headaches I was having regarding timezones... I'd highly recommend it if you have the luxury of changing the incoming data format.
Whilst I'm not sure why yours doesn't parse, I would question the ZZ instead of the ZZZ at the end given you have +01 not +1?
I have finally resolved that issue.
I'm modifying date format and date string to remove microseconds so I can parse date properly. Then I just add microseconds parsed from original date string.
I have strings in the following format e.g. 20110201 and I want to convert it to a date in delphi, then subtract it from today to get the number of days difference.
How can I do that?
Sorry for my english.
The functions you need are Copy (to retrieve parts of your input string), StrToInt (to convert the string parts to integers), DateUtils.EncodeDate (to create a TDate from the integers), Now (to retrieve the current date as TDate) and DateUtils.DaysBetween (to get the difference between two dates in days).
I think you can figure out the rest on your own using the Delphi help for these functions.
Use Copy to extract the 3 substrings for year, month, day. Then StrToInt to convert them into integers, then EncodeDate to turn the 3 integers into a TDateTime.
TDateTime is a float, counting whole days before the decimal point and the time at that day as the fraction after the decimal point.
In SysUtils there is a function called Date: TDateTime which returns the current date.
You can simply substract the TDateTime you parsed out of the string from the value returned by Date to get the number of days difference between them.