Switch date and month google sheet - google-sheets

I have a data column which date in this format 05/12/2021 = dd/mm/yyyy but google sheet see it as 05/12/2021 = mm/dd/yyyy, how can I use a formula to switch the day and month around and display as 5/12/2021 = d/mm/yyyy. It has to be done on a formula level as there are many other dates column that has the format and information right.
Formula tried
=TEXT(A3:A,"d/mm/yyyy")

If the date is entered correctly, you should be able to format it by going to the 'Format' menu.
However, if you need to transpose the formatted day and month using formula, then try this in row 3 (any column but A):
=arrayformula(datevalue(regexreplace(to_text(A3:A),"(.|..)[\/\-\.](.|..)[\/\-\.](.*)","$2\/$1\/$3")))

Related

Data Validation + VLOOKUP for Month in Sheets

So I'm currently setting up a sheet that records weekly numbers. I'd love to have something that summarizes the totals (money in, loss, etc) by month. So if the week = 4/4/0 this is April (4) and is calculated just by a drop-down of months. Is such a thing possible in Sheets? I don't need the formula just the clue, really.
Update:
I found something similar:
=SUMIFS($N$7:$N$11,$M$7:$M$11,">="&S8,$M$7:$M$11,"<="&EOMONTH(S8,0))
N7:N11 is amount
M7:M11 is date
S8 is the date I'm querying for
The issue I have with that (^^) formula is that it wants me to present the date as D-MONTH-YYYY
but I'd love the date to just be the MONTH
You can set the column to show just the month by setting its format:
and creating a "Custom date & time"
Alternatively, you can use text to represent the months and convert them to number representation using MONTH(S8&1)
Then, you can do some funky way of converting the "month" to "date" using DATE(YEAR, MONTH(S8&1), 1), where "year" is the year you're querying for.
To sum it up, the formula from your question might look something like this:
=SUMIFS($N$7:$N$11, $M$7:$M$11, ">="&DATE(2022, MONTH(S8&1), 1), $M$7:$M$11, "<="&EOMONTH(2022, MONTH(S8&1), 1),0))

How to Use formula to insert Month to Date Automatically

I want to use a single formula in cell A2 to insert Month to date Automatically. (in descending order). Only show date within this month (September)
For example, Today is 9/2/2021.
It will show:
9/2/2021
9/1/2021
Let's say we entering the next day 9/3/2021.
It will show:
9/3/2021
9/2/2021
9/1/2021
https://docs.google.com/spreadsheets/d/1Rq7_yGZjXEqN84BIKmmZ0a8qlcPF2ZIgvdCD2aorGKc/edit?usp=sharing
Thank you so much for your help.
Try this in A2 based on the date from B1:
=arrayformula(sort((eomonth(B1,-1))+(sequence(B1-eomonth(B1,-1),1)),1,0))
or this using today():
=arrayformula(sort((eomonth(today(),-1))+(sequence(today()-eomonth(today(),-1),1)),1,0))

Date Conversion in Google Sheets

I am struggling to convert a bunch of dates in Google Sheets.
My dates are in the format mentioned in this image.
Some dates have AM/PM in them, while some have a / instead of a -.
I need to convert them to yyyy"-"mm"-"dd" "hh":"mm":"ss while converting the time to 24hour format in case of PM.
Does anyone know a way to achieve this?
The problem is that most of your data uses the American date convention m/d/yyyy while your spreadsheet uses the Indian d/m/yyyy date convention. But then again, some of the data appears to already be in the ISO8601 format you are requesting as the result format. To convert all the dates, use this:
=arrayformula(
if(
isnumber(A2:A) + isblank(A2:A),
A2:A,
regexreplace(A2:A, "^(\d+)/(\d+)/(\d+)(.+)", "$3-$1-$2$4") + 0
)
)
Format the result cells as Format > Number > Date time or as the custom format you mentioned. See the new Solution column in your sample spreadsheet.
Suppose your raw data is in A2:A. Clear B2:B and place the following into B2:
=ArrayFormula(IF(A2:A="",,IFERROR(DATEVALUE(A2:A&"")+TIMEVALUE(A2:A&""),DATEVALUE(A2:A)+TIMEVALUE(A2:A))))
This formula has error control built in, to handle the raw data if there is a mix of strings and real date-times.
Next, select the entire Column B. Apply Format > Number > More Formats > Custom number format and enter the following in the text field at the top: yyyy-mm-dd hh:mm:ss

Highlight Duplicate Within 24 hours timestamp but a different date

I am trying to figure if the following can be done. If there are duplicate names in the B column then it will see if the date and time were within 24 hours of each other in the A column, if so it will highlight the cell yellow.
Currently, the formula I have will only highlight if it was on the same date. Is there a way I can add to the formula to all take into account time? So that if one response is on 5/20/20 at 17:00 and the next duplicate name is at 5/21/20 at 16:00 then the cell would be highlighted.
Here is the formula I am using the just highlights if it is within the same date:
=ARRAYFORMULA(COUNTIFS(B:B, B2, DATEVALUE(A:A), DATEVALUE(A2))>1)
I am not sure if something like this is possible. I am guessing that the formula would have to compare both datevalue and timevalue. Any help would be appreciated.
Instead of DATEVALUE you can use TO_PURE_NUMBER
This will return you the number of days from January 1, 1900 including the fraction for past hours and minutes opposed to DATEVALUE that rounds the value down to an integral day number.
Sample:
This allows you to calculate the real difference time between your timestamp.
For example like this:
=ARRAYFORMULA(or(COUNTIFS(B:B, B2, TO_PURE_NUMBER(A:A), ">"&TO_PURE_NUMBER(A2)-1, TO_PURE_NUMBER(A:A), "<"&TO_PURE_NUMBER(A2))>0,COUNTIFS(B:B, B2, TO_PURE_NUMBER(A:A), "<"&TO_PURE_NUMBER(A2)+1,TO_PURE_NUMBER(A:A), ">"&TO_PURE_NUMBER(A2))>0))

How do I use a query on a timestamp to filter down to "day of the week" and "hour"

Currently I am able to Query my data by the date in a timestamp but now I want to narrow it down to the hour and the day
=COUNT(QUERY('Form Responses 1'!$A$2:$E, "Select A where A>=date '"&TEXT(B$5,"yyyy-mm-dd")&"' and A <= date '"&TEXT(B$6,"yyyy-mm-dd")&"'")
I am attempting to build a grid of when my responses come in by date and time over the hour
Date ranges have to be dynamic. I need to go look at a sample of data over a week or a sample of data over a year
How can I add a conditional time and day statement to this?
This is what I want to do
Each cell will be it's own query formulaenter image description here
Try this:
=COUNTIFs(ArrayFormula(WEEKDAY(A:A)),"=1",ArrayFormula(hour(A:A)),"=8")
Where a:a is the array containing your timestamps. This example would populate the Monday at 8 am category.

Resources