I'm having trouble with two formatting issues that I would really appreciate help with:
1) The Days Open column is displaying the number of days properly, but the column name is being overwritten by my conversion command, and
2) I need the Order Date (OOpenDate) to be displayed in the "MM/DD/YYYY" format
Code:
column O_Num heading 'Order|Number' format a6
column OOpenDate heading 'Order|Date' format a10
column (sysdate-OrderOpenDate) heading 'Days|Open' format a4
select O_Num, OOpenDate, to_char(sysdate-OOpenDate, '999')
from Orders
where Status = 'Open';
What its currently displaying:
Order Order
Number Date TO_C
------ --------- ------
100 03-DEC-13 14
What I want it to display as:
Order Order Days
Number Date Open
------ --------- ------
100 12/03/2013 14
Thank you in advance!
The simplest approach would be to alias the "Days Open" column and apply the format mask to the alias
column days_open heading 'Days|Open' format a4;
select O_Num, OOpenDate, to_char(sysdate-OOpenDate, '999') days_open
from Orders
where Status = 'Open';
Otherwise, the column name in your column command would need to exactly match the expression in your SELECT statement (including the to_char, any spaces, etc.) That's possible but it generally makes things rather hard to maintain.
Related
I am trying to build a sleep tracker in Google Sheets (link). The idea is to select a year and a month from a drop-down list in cells A1 and A2, which would then populate columns based on the number of days in that month. I have tried different formulas that I found on stack overflow and elsewhere, but could not get them to work.
In short:
I am looking for a formula that will populate the columns with days of that month and a name of the day in a row bellow.
Looking for a way to summarize the time of sleep at the end of the each day, based on a ticked checkbox.
I am not sure how the year and month selectors should be formatted (as plain number or a date).
Is there a way to automatically insert check-boxes to the days of the month?
This is the formula that I have tried to adjust:
=INDEX({TEXT(SEQUENCE(1; DAY(EOMONTH(A2&"/"&A1;0)); A2&"/"&A1; 1); {"d"; "ddd"}); {"Total"; ""}})
But it returns with "Error In ARRAY_LITERAL, an Array Literal was missing values for one or more rows."
Please note that ";" is used as an argument separator instead of "," (regional settings).
Thank you in advance!
I think that with a very small adaptation and date formatting you'll be able to easily do it. First with your selector in A2, you could set it as actual dates, but format them as mmmm:
Then, repeat the sequence in both rows starting in C2 and C3:
=SEQUENCE(1,DAY(EOMONTH(A2,0)),A2)
But formatting row 3 as ddd:
PS: yes, you can do row 3 with TEXT and INDEX. Choose your preferred one:
=INDEX(TEXT(SEQUENCE(1,DAY(EOMONTH(A2,0)),A2),"dddd"))
UPDATE with TEXT VALUES
Return to your previous A2 dropdown and try this, using MATCH to find the number of the month, and DATE to locate the correct beginning of the month in that year:
For row 2:
=SEQUENCE(1,DAY(EOMONTH(DATE(A1,MATCH(A2,{"January","February","March","April","May","June","July","September","October","November","December"},0),1),0)),
DATE(A1,MATCH(A2,{"January","February","March","April","May","June","July","September","October","November","December"},0),1))
For row 3:
=INDEX(TEXT(SEQUENCE(1,DAY(EOMONTH(DATE(A1,MATCH(A2,{"January","February","March","April","May","June","July","September","October","November","December"},0),1),0)),
DATE(A1,MATCH(A2,{"January","February","March","April","May","June","July","September","October","November","December"},0),1)),"dddd")
)
I can't figure out how to solve my issue in google spreadsheet.
I have a column with some packages we want to release on our website on specific random dates. Not all fields in these column are populated, some are empty. For the populated ones I want to assign a random number between a range (A,B) which I take from other fields and have a max number of duplicates (the number of duplicates I take from another field).
For example I have 60 packages and I need to assign them between 1 and 31 (days of current month) so that means I will have 2 duplicates/day and I will put my duplicate field value to 2. But these 60 packages are shown in 80 rows for example, 20 rows empty, so those must not have any number assigned to them.
I have tried a few solutions with RANDBETWEEN and SORT etc but I did not manage to make it work. Now I switched to writing a custom function but I have never written one in google app scripts before, so if any of you guys have experience with this I would highly appreciate.
Random dates
Use this formula to get random dates between start date and end date appended randomly and duplicated only twice.
=ArrayFormula(IF(A2:A="",,
VLOOKUP(A2:A,
{SORT({ FILTER(A2:A,A2:A<>""),
RANDARRAY(COUNTA( FILTER(A2:A,A2:A<>"")),1) },2,1),
TRANSPOSE(SPLIT(REPT(TEXTJOIN(";",1,($E$1+SEQUENCE(DATEDIF($E$1,$E$2,"D"),1,1)))&";",$E$5),";"))},3,0)))
Sort chronologically
01 - paste in G2.
=SORT(QUERY(UNIQUE(QUERY({B2:B},"Select * where Col1 is not null ")), "where Col1 is not null"),1,1)
02 - paste this formula in H2 and drag down.
=IF(G2="",,TEXTJOIN(", ",1,FILTER($A$2:$A,$B$2:$B=G2)))
I'm trying to concatenate a column of dates and other of hours.
The fuction:
=CONCATENATE(TEXT(AGENDA!B9 ,"dd-mm-yyyy"), " ", TEXT(AGENDA!C9 ,"hh:mm:ss"))
works, but, some cells are in fuction format, dd-mm-yyyy, and some others are dd/mm/yyyy (the time is correct). I need them all with -
You have a non valid date in AGENDA sheet Fecha column note Luque, Hugo 20/08/2021 with month set to 20 !! and day is 08.
To add date validation, Select B2:B and go to Data data > validation > Criteria: date.
and select On invalid data: Show warning.
Fix the date one by one or take a look at the quick fix.
To check the date format:
Go to Formst > number > Custom date and time.
The Quick fix
To get date fixed with a formula from, mm/dd/yyyy to dd-mm-yyyy you need a helper column lets call it Fixed Date, with the formula.
=IF(ISDATE(B2)=False,CONCATENATE(INDEX(SPLIT(B2,"/-"),1,2),"-",INDEX(SPLIT(B2,"/-"),1,1),"-",INDEX(SPLIT(B2,"/-"),1,3)),B2)
Explanation
1 - IF(ISDATE(B2)=False check the date is valid if true return the original value example B2 if false calculate the formula.
2 - INDEX(SPLIT(B2,"/-"),1,2) to get the month column that resulted from SPLIT function with column set to 2.
3 - INDEX(SPLIT(B2,"/-"),1,1) to get the day column that resulted from SPLIT function with column set to 1.
4 - INDEX(SPLIT(B2,"/-"),1,3)) to get the yaer column that resulted from SPLIT function with column set to 3.
5 - CONCATENATE the columns with "-" in between.
Now you can paste your formula but adjusted in BBDD.AGENDA Sheet B3 cell.
=TEXTJOIN(" ",TRUE,TEXT(AGENDA!C2 ,"dd-mm-yyyy"),TEXT(AGENDA!D2 ,"hh:mm:ss"))
Notice that we changed AGENDA!B2 with AGENDA!C2.
I'm sorry to ask this, I have not any code skills and I've trying to figure that out for a few hours now.. I think an image will be better for you to understand what I want:
I want A2 to show the sum of the products in G:G that fit certain conditions (2020,jan,buy). I haved tried several formulas but I came up with this one as the closest, I think, but still won't work:
=arrayformula(SUMIFS(E:E=B1,F:F="jan",G:G="buy",H:H))
Can anyone explain me how to achieve that?
Thanks very much :)
Please use this formula in A2 it will work
=sumifs(G2:G100,D2:D100,2020,E2:E100,"jan",F2:F100,"buy")
So basically, sumifs formula is right one as you want to check for multiple conditions.
so this is how this formula work
=sumifs(sum_range,criteria_range1,criteria1,criteria_range2,criteria2,...)
In your case your same range is column 'G' so if you have a finite range like only 25 rows you have in your table then instead of G2:G100 you can use G2:G25 as G1 is containing label and make sure that all other ranges also similar to the range of column G. for example if you take range of G2:G100 means 99 rows then you should take E2:E100 or E3:E101(range of 99 rows, that rows must be 99 and series start and end number is as per your requirement, similar case for other columns in this formula)
you have to check 2020 in column D, so you criteria_range1 is of D column I took it D2:D100 and criteria 1 is 2020 as it's a number it doesn't need double quotes
criteria 2 is you need to check Jan in column E so criteria_range2 is column E I took it E2:E100 and criteria 2 is "jan" as it's not a number so I took it in double quotes.
criteria 3 is you need to check 'buy' in column F so Criteria_range3 is column F. I took it as F2:F100 and criteria 3 is "buy" again it's not a number so took it under double quotes.
So what I have so far is a spreadsheet that will auto time stamp column N when my technicians enter their initials into column M.
Now the 2nd thing I would like the spreadsheet to do is.
When I enter the hours (example: 1.8) into column E "HRS." And have the spreadsheet put the HRS. into the correct Technicians column. Based on the initials entered in column M "Tech Up".
Example: if E4=1.8 it would put 1.8 into G4 because M4=AB
Example: if E6=3.2 it would put 3.2 into J6 because M6=JW
Does anyone know what type formula this would require? Or where I might look to find one?
If the data starts in row 4, and the individual technician columns start at column G, try in G4:
=ArrayFormula(IF(E4:E*(M4:M={"AB","CD","GM","JW","RT"});E4:E;IFERROR(1/0)))
and if the initials of the technicians are already in G2:L2 as headers:
=ArrayFormula(IF(E4:E*(M4:M=G2:L2);E4:E;IFERROR(1/0)))
Notes if using the first option:
Change the initials in the embedded array to match your columns
If your spreadsheet is set to a locale that uses commas as a decimal, change the commas in the embedded array to \