How to i change the date time format on Google Sheets? - google-sheets

I am working on a datasheet on Google sheets and I am trying to change values in column (D) to date time format, so I went to Format<number<date time. But only a few values are getting converted and the rest remain the same. Please see below-
Screenshot of column D
The values aligned on right are converted and the left ones aren't. I even tried paint format, trim white spaces but it didnt work. Please suggest a way on how to resolve this error. Also, there are 49623 values in column D.
thank you

Your spreadsheet is set to a locale that uses the mm/dd/yyyy date format, while your data is using the dd/mm/yyyy date format. That means that the dates where the day of the month is less than or equal to 12 will get converted to dates incorrectly, and the rest of the data will remain as text strings.
To make it work, choose File > Settings > Locale and choose a locale that matches your data, then repaste the data to convert it correctly.
The "49623 values" are dateserials that can be converted to dates by formatting them in a date format. See this answer for an explanation of how date and time values work in spreadsheets.

Related

Dates standardization in Google sheets using formulas

I have some raw data coming from a system. the issue is that system exports the dates using the US formating to be as M/D/YYYY meanwhile all my sheets using dates as DD/MM/YYYY or D/M/YYYY. i tried using this formula
=text(TO_DATE(DATEVALUE('Row Data'!A2)),"M/D/YYYY")
and then the date changes from e.g. 6/1/2021 to 1/6/2021 (here for June 2021) but after the date is becoming 1/6/2021 i think the other formulas are still reading the date as if it is already the same as 6/1/2021.
Here is a sheet that has some data that I'm struggling with Dates Standardization
So any idea how to fix this mess?
Appreciate your help <3
Based on the formula you've already tried, does this work instead?
=date(regexextract(to_text('Row Data'!A2),".*\/(.*)"),regexreplace(to_text('Row Data'!A2),"\/.*",""),regexextract(regexextract(to_text('Row Data'!A2),"(.*)\/.*"),".*\/(.*)"))
Alternative:
=datevalue(regexreplace(to_text('Row Data'!A2),"(.|..)\/(.|..)\/(.*)","$2\/$1\/$3"))
Assuming you have US dates supplied in any of these formats:
M/D/YY
M/D/YYYY
MM/DD/YY
MM/DD/YYYY
M-D-YY
M-D-YYYY
MM-DD-YY
MM-DD-YYYY
M.D.YY
M.D.YYYY
MM.DD.YY
MM.DD.YYYY
To switch day with month, this will work relative to the example screengrab below:
=arrayformula(if(A1:A<>"", datevalue(regexreplace(to_text(A1:A),"(.|..)[\/\-\.](.|..)[\/\-\.](.*)","$2\/$1\/$3")),))

How to count numbers in text format in a google sheets

I am importing a excel data to google sheets. Upon importing the numbers in excel sheet changes its format to text.
now the functions like countif() and sumif() doesnt work when the numbers are in text format?
Please suggest any work around for this ?
Thanks in advance
Preeths
Select all the cells which are numbers and change the format to numbers (Use the format menu to format as Number). Keep in mind the Spreadsheet settings and locale for the setting of decimal separator (comma or point).

Debug a numeric value in a date column SQL

I have a couple of queries running in Google Sheets via Supermetrics.
These all have a column with the date ('2020-05-26') and a numeric column Cost ('3450')
Sometimes in rerunning these queries one of the rows does not show a date format, but a date formatted as number, e.g. '43976' for 2020-05-25. I am importing the sheets in Big Query, but when importing the date column as a date format, I get an error whenever there is one row formatted as a number.
I tried using an arrayformula in Google Sheets to overcome the formatting issue there, but that does not work since you cannot import a column with aan array formula in Google sheets.
I tried importing the column as a string, that works. Now however, I need to make sure all rows are recognised as a date. I used the following formula to change the string into a date, but again that one row formatted as '43976' will block the whole query.
How do I convert a string column, with both values formatted as a date "2020-05-25" and values formatted as a number '43976' to a date column? Thanks for your help!
Hereby a screenshot; however, the formatting is overwritten by the supermetrics query that is run daily, so just changing the formatting in the column here won't help (it will fix it for this day, but not going forward) - I've tried that already..

How to Count Timestamp on Google Spreadsheets?

My responses are timestamped as soon as anyone submits a survey. I wanted to count those timestamp monthwise.
URL - https://docs.google.com/spreadsheet/ccc?key=0AkpZp6MVqYv1dE5SZjJIODB1WF9nZDR6b1ZJZjFPenc&usp=sharing
I wanted to find out number of positive responses for a particular question (lets say Q1) for a particular month (lets say May)
Column G is not founded out based on the timestamp of Q1, I had asked the user the month, but that's not the correct way to do so, so I have stopped asking the user to enter the month.
First you have to overcome the fact that the timestamp isn't compatible with googles date format. No biggie,... luckily it looks like you have a fixed format ie DD/MM/YYYY. So you can use the LEFT and RIGHT formulas like so =right(left(a2,5),2) This will give you the month in text, ie 05.
Great.
Now for the harder stuff. If you have the newer google spreadsheets, you can simply use countifs to the effect of:
=countifs(arrayformula(right(left(A$2:A,5),2)),"=05",B$2:B,"=Positive")
For each month, replace the "=05" with the the date number you want. You could also make a month lookup chart for all months and questions so that you don't have to modify the formula for each month and quesiton. For this you replace the "=05" with =[cell number containing month number as text] (NOTE: for making a lookup key, you will have to pay close attention to the fact that you are getting TEXT in the formula above vice a number. There is a difference and they are not compatible as-is.)
Let's say you don't have the new google spreadsheets. Then you can use the old sumproduct() and if(). Yes, it is old. See the following:
=sumproduct(arrayformula(if(right(left(A$2:A,5),2)="05",1,0)),arrayformula(if(B$2:B="Positive",1,0)))
Note in both of these, you need to use arrayformula to convert the column with the timestamp into something useable. If you want to make this part easier by removing the parseing functions (LEFT() and RIGHT()) you need to change the timestamp format to be MM/DD/YYYY. Then you can plug in the the MONTH(DATE) formula and it will be done.
Then make a master sheet like so (note my formula has a "'" in it to make it visible for purposes of demonstration, you should remove it.):
Careful inspection might note that the count is wrong. That is because when I imported your timestamps, times like "02/06/2014 ..." were interpreted to mean "February 06" because of google's auto-formatting. In your sheet you will get the correct count using this formula, because of the way your timestamp is auto-populated.
HINT: To make the month a text you need to enter ="05" in the Month column
Please let me know how you make out.

change date format in sqlite

Change this date format which is in sqlite db 12/10/11 to 12-10-11 (mm-dd-yy) I am unable to do so .I am a noob in sqlite and have to parse this value SELECT strftime('%d-%m-%Y',Date) from report but I am getting null as sqlite db excepts value in mm-dd-yy so How do I convert format 12/10/11 to 12-10-11 (mm-dd-yy) .Thanks in advance .Really appreciate the help.
The short answer:
If you have a text string stored as "12/10/11" that you want reported as "12-10-11", you should use the replace(X,Y,Z) function, to replace occurrences of Y in X with Z. Thus:
SELECT replace('12/24/11','/','-');
will return:
12-10-11
The long answer:
First, dates do not actually exist as a proper datatype in SQLite. They're stored as either TEXT, REAL, or INTEGER values. See date and time datatype in SQLite. So it depends upon how your date was stored in the database.
Second, you seem to be implying that you stored the date in a "mm/dd/yy" format. That's not a valid/useful TEXT format to be storing date/time values (as the date cannot be sorted, cannot used in "greater than" and "less than" operations, cannot be used in SQLite date functions, etc.). You really want to store datetime values in one of the formats listed in the "Time strings" section of the date and time functions document.
So, generally you should store your date/time values in one of those formats, use NSDateFormatter to convert that to a NSDate when you retrieve it from the database. And when you want to display the date value in your app, use whatever format you want for output.
But, if you don't care that the dates are stored as text strings and are not effectively usable as dates in SQLite, then just treat it as a plain old TEXT string and use TEXT functions, such as replace(X,Y,Z) to replace occurrences of "/" with "-", as outlined above.

Resources