I have a time indicator looking like this:
2002-01-01T05:00:31.217Z
I want to separate this in
day ("yyyy-mm-dd") and time("hh:mm:ss") in tzo different rows.
Command =text(field, "yyyy-mm-dd") does not work, it still displays 2002-01-01T05:00:31.217Z
The application is google sheets. How can I separate it correctly?
use:
=INDEX(SPLIT(A2:A, "TZ", 1))
if you want to reformat it:
=INDEX(TEXT(SPLIT(A2:A, "TZ", 1), {"dd/mm/yyyy", "hh:mm:ss"}))
Related
I text based .csv file with a semicolon separated data set which contains date values that look like this
22.07.2020
22.07.2020
17.07.2020
09.07.2020
30.06.2020
When I go to Format>number> I see the Google sheets has automatic set.
In this state I cannot use and formulas with this data.
I go to Format>number> and set this to date but formulas still do not see the actual date value and continue to display an error
Can someone share how I can quickly activate the values of this array so formulas will work against them?
I would be super thankful
Where the date are in column A, starting in cell A1, this formula will convert to DATE as a number, after which you apply formatting to Short Date style.
=ARRAYFORMULA(IF(A1:A="",,DATE(RIGHT(A1:A,4),MID(A1:A,4,2),LEFT(A1:A,2))))
Hopefully(!) the dates stay as text, otherwise Google Sheets would sometimes detect MM/dd/yyyy instead of dd/MM/yyyy, and you won't be able to distinguish between July 9th and September 7th in your example.
Solution #1
If your locale is for instance FR, you can then apply
=arrayformula(if(A1:A="";;value(A1:A)))
solution#2
you can try/adapt
function importCsvFromIdv1() {
var id = 'the id of the csv file';
var csv = DriveApp.getFileById(id).getBlob().getDataAsString();
var csvData = Utilities.parseCsv(csv);
csvData.forEach(function(row){
date = row[0]
row[0] = date.substring(6,10)+'-'+date.substring(3,5)+'-'+date.substring(0,2)
})
var f = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
f.getRange(1, 1, csvData.length, csvData[0].length).setValues(csvData);
}
First thanks to those that suggested a fix. I am not really a programmer and get cold sweats when I see suggesting of running scripts to solve simple problems. Sorry guys.
So the (non programmer) solution with the dates was to do a find/replace (CTRL + H) and replace all the (.)dots with (/)slashes, then to make sure the column is formatted as a date, then Google finally understands it as a date.
With the accounting values as well, I had to do the same find/replace to remove all the ' between thousands, then google woke up and understood them as numbers.
I am significantly underwhelmed by this from Google. They are getting too fat and lazy. They need some competition.
I am trying to use VLookup or QUERY to extract a day and time description based on the current date and time. I thought QUERY may be the best here, but VLOOKUP seems to be the best solution perhaps.
Is it possible to extract the date from between date and time ranges? The descriptions may change frequently so they can't be hardcoded into the formula.
Here is the Google Sheet, which can also be copied.
https://docs.google.com/spreadsheets/d/1efQo1t9FJbItYdf1OQJ4vzeG1bUaQ1R0vbFGsgIjzOI/edit?usp=sharing
This was the current formula, which I hoped would extract the correct date and timeslot description
=ARRAYFORMULA(IFERROR(TEXT(A2:A, "dddd ")&VLOOKUP(TIMEVALUE(A2:A), {
TIMEVALUE(IFERROR(REGEXEXTRACT(TimeDescription!A2:A, "(.*) -"))), TimeDescription!B2:B}, 2, 1)))
based on your time data logic try:
=ARRAYFORMULA(IFERROR(TEXT(A2:A, "dddd ")&VLOOKUP(TIMEVALUE(A2:A), {
TIMEVALUE("00:00"), "Evening";
TIMEVALUE("07:00"), "Breakfast";
TIMEVALUE("09:00"), "Morning";
TIMEVALUE("16:00"), "Daytime";
TIMEVALUE("20:00"), "Evening"}, 2, 1)))
for non-hardcoded references use:
=ARRAYFORMULA(IFERROR(TEXT(A2:A, "dddd ")&VLOOKUP(TIMEVALUE(A2:A),
SORT({TIMEVALUE(REGEXEXTRACT(TimeDescription!A2:A, "(.*) -")),
TimeDescription!B2:B}, 1, 1), 2, 1)))
spreadsheet demo
If you have =NOW() in A2, this formula should work without any additional tabs or descriptions...
Apologies, i'd originally Missed the necessity of the day of the week as well. This should work. Again, just with NOW() in A2 and nothing else on the sheet.
=ARRAYFORMULA(JOIN(" ",VLOOKUP(MOD(A2,{7,1}),SORT({{{7;9;16;20}/24;SEQUENCE(7,1,0)},{"Breakfast";"Morning";"Daytime";"Evening";TEXT(SEQUENCE(7,1,0),"dddd")}}),2)))
I'm trying to put a query in one google sheet tab that pulls in data from another tab (Called Confirmed Shoots), based on one "date" column in the Confirmed Shoots tab. I want to pull in anything from the current week, probably taken from the week number (WEEKNUM).
I have a similar formula working in another tab where I'm pulling in everything scheduled for tomorrow, which is:
=query('Confirmed Shoots'!A1:Y,"Select G,J,I,H,C,E,F,K,L,N,D Where G=date"""&text(TODAY()+1,"yyyy-mm-dd")&""" ")
I also found a way to pull "this week" from a date with this IF formula-
=IF(WEEKNUM(G2)=WEEKNUM(NOW()),"Yes","")
I'm struggling with the syntax, trying to combine the two. I want it to be something like:
=query('Confirmed Shoots'!A1:Y,"Select G,J,I,H,C,E,F,K,L,N,D Where (WEEKNUM(G2)=WEEKNUM(NOW()),"yyyy-mm-dd")&""" ")")
or
=query('Confirmed Shoots'!A1:Y,"Select G,J,I,H,C,E,F,K,L,N,D Where (WEEKNUM(G2)=WEEKNUM(NOW())
Both of these are giving me errors though. Does anyone know how to do this? Thanks!
Try:
=FILTER(QUERY('Confirmed Shoots'!A1:Y,"Select G,J,I,H,C,E,F,K,L,N,D"), WEEKNUM('Confirmed Shoots'!G1:G)=WEEKNUM(NOW()))
I want to display formatted month name in the basic form (nominative) as a label. In Czech language (and several next Slavic languages) we use declension. So if I use =TEXT(NOW();"MMMM") the cell shows month name in genetive instead of nominative (i.e. srpna instead of srpen).
Q: How to format the date in the nominative? The acceptable solution will offer some native way how to solve it but not:
manipulating with strings (month names are too complex)
having some another list with month names
calling own formula (Google script)
Maybe there is no native way how to solve this and it will be implemented in the future, so Google Script seems to be the easiest hotfix for now. And because I'm expecting many answers with the script, I'm putting the one here but this question is not about the javascript/google-script.
function monthName(date) {
var months = ["Leden","Únor","Březen","Duben","Květen", "Červen","Červenec","Srpen","Září","Říjen","Listopad","Prosinec"];
return months[date.getMonth()];
}
I'm using PowerBuilder 10.5 and I have two single line edit (SLE) fields - sle_date1 and sle_date2 on my window.
What I need is for those two fields to be filled once I open my program. sle_date2 has to have the value of today (for example - 09.07.13), and sle_date1 has to have the value of (sle_date2-30 days) (example 09.06.13).
So, as I said, once I open my programs both fields would be filled immediately with values of today's date and the date of a month before.
How could I do that? Any advice just to get me going?
You can add some code to populate the edits in the open() event of your window
with a given date that can be today(), you can compute a new date plus / minus a number of days with RelativeDate()
The following code just answers your question (though it could be better to use some editmask controls instead of singlelineedit as it would ease the handle of user's input):
date ld_now, ld_previousmonth
string ls_datefmt
ls_datefmt = "dd.mm.yy"
ld_now = today()
sle_1.text = string(ld_now, ls_datefmt)
ld_previousmonth= RelativeDate(ld_now, -30)
sle_2.text = string(ld_previousmonth, ls_datefmt)
It shows 09.07.13 and 09.06.13 at this time.
first of all you need to open your window. You can to this with put this code in your application open event (let suppose that your window is w_main):
open(w_main)
After that in put this code in your window's open event:
sle_date1.text = string(today())
sle_date2.text = string(RelativeDate(Today(), -30))
I think this solves your problem. Here is a little help for RelativeDate:
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.pocketbuilder_2.0.pkpsref/html/pkpsref/pkpsref662.htm
Best Regards
Gábor