Use Current Month to Get Sheet Name - datetime

I have a series of sheets named: JAN 2022, FEB 2022, etc.
I have a cell that is pulling E2 from the sheet as ='JAN 2022'!E2
I want to pull the E2 value for the current month. I tried using the following, but it doesn't work:
='(CONCATENATE(TEXT(today(),"mmmm")," ",2022)'!E2
Please advise.

Give this a try
=INDIRECT(text(today(),"mmm "&2022)&"!E2")

try: =indirect(upper(text(today(),"mmm yyyy"))&"!E2")

Related

how to transform Carbon date into m-d-y format? (opposite)

I've this date format: November 12, 2018 and I want to transform it into (m-d-y) format to be able to insert it into DB (as dynamic data..). Any help will be appreciated.
checked most of the answers, all are talking how to convert from (d-m-y) into Carbon (human format) .. I couldn't find something for this.
Using 'Carbon', this will return the desired date format which is: 2021-12-27
Carbon::parse('December 27, 2021')->format('Y-m-d');
note: I'm using Laravel framework.

Need to extract date from a text file of strings in R

I have a text file. It contains lots of text in following format:
text
text
Date in format of 12 December 2016
text
text
How do I extract only the date in such a case given that there is no other date in the text section of the file? Need a R program for it.
This would do the trick. You would get the the dates parsed while the rest would become NA objects which you can filter out.
text=c('a','b','12 December 2016','10 December 2015')
strptime(text,format='%d %B %Y')
I've called your data set demo_set for practical purposes.
You start by reading in your data set:
demo_set=readLines(con <- file("yourFile.txt") #read in file.
You can use other ways of reading in your data set.
Then you use regex to find lines with month names.
demo_set[grep(pattern = paste(month.name,collapse = "|"),demo_set)]
If your text doesn't starts with number you can use the below code
abc<- subset(abc, grepl("^[0-9]",name))
where abc is your dataframe and name is your column in your dataframe
You can also use an if statement to check if there are any values within a column such as Date, and print them to screen like so;
if(!is.na(data$date)) {
print(data$date)
}
This will print all the records where there is a value in Date but if you would rather just a sample, use;
print(data$date[1:10])

Converting "January 5th" and "February 1st" to dates (removing ordinals/th/rd/st)

I have ~100 rows of live data from a website that look like this:
January 24th 12:30pm NINJA Party
January 31st 3:30pm Classic Party
How can I get Google Sheets to recognize the dates? It doesn't recognize the ordinal endings (e.g. th/st/rd).
Thank you.
This formula might work as you want (amend the A2:A range as required):
=ArrayFormula(IF(A2:A="",,(IFERROR(DATEVALUE(LEFT(A2:A,SEARCH(" ",A2:A)+2)),DATEVALUE(LEFT(A2:A,SEARCH(" ",A2:A)+1))))))

QDate - wrong year

I have the following situation:
QDate fixDate = QDate::fromString(QString("270912"), "ddMMyy");
the year returned is 1912. I do not understand why and how get the correct year.
Thanks in advance
Two-digit year is always interpretating as 19xx.
So You can pass YYYY or just add 100 to years.
As described in the docs:
For any field that is not represented in the format the following defaults are used:
Year 1900
Month 1
Day 1
// For example:
QDate::fromString("1.30", "M.d"); // January 30 1900
QDate::fromString("20000110", "yyyyMMdd"); // January 10, 2000
(Excuse the formatting, it's in a table in the docs). So you are going to have to pass the full year into the method until Qt decide 2012 is far enough into the century to change the default...
Could you use ddMMyyyy instead of ddMMyy? Or you need date in this format?
Look here for more information about fromString method

Possible to create a query that sorts by day of week?

Is it possible to write a SQL query that sorts data set by day of week starting from a specific day?
For example, if today is Thursday, the results are sorted from THU-FRI-SAT-...-MON-TUE-WED.
If today is Tuesday, the results would be sorted from TUE-WED-THU-...-SAT-SUN-MON.
Days are stored as integers.
Assuming you have the day of the week stored into field WD where value 1 means MON, 2 means TUE etc and SW is the "start of the week" index (again 1:MON, 2:TUE,...) then something like
CASE WHEN WD < SW THEN WD + 7 ELSE WD END
should give you a value to order by. I don't use sqlite so I'm not sure can you put it right into the ORDER BY or do you have to use it as a field and then order by that field.
in mysql: ORDER BY DATE_FORMAT(date,%w)
see: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format
Microsoft databases suport this (not shure)
... ORDER by DATENAME ( dw , table.datefield )
Check out DATEPART:
http://www.tizag.com/sqlTutorial/sqldatepart.php

Resources