google sheets formula to extract time check in and checkout - date

Can someone help me with a formula to extract time from a specific checkin and checkout timestamp?
Here is an example of the time stamps:
Check-in = 2022-09-01T04:55:37
Check-out = 2022-09-01T08:00:44
In the check-in example, I would like to extract the 04:55 value and 08:00 in the check-out value.
I've tried =MOD, = Time,Minute, and Timevalue but it doesn't work.

use:
=INDEX(SPLIT(A1:A2; "T");;2)

Related

Google Sheets - DATE format not working on imported Date in TEXT format

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.

How to extract year only from email date

I'm reading an entire Gmail emails (inbox/sent/trash...), and try to create folders in google drive according to dates.
So folders should be categorized like (...,2019,2020, 2021). Each folder contains all emails in this year in my Gmail.
I managed to create the folders, getting messages through using Threads, all these things works fine, but I couldn't extract the year of the message only.
As when I use Threads[0].getMessages()[0].getDate() what is returned is date and time of this message. which I can't extract the year only from it.
I tried to split the date, but this is not string.
I tried to make smth like Threads[0].getMessages()[0].getDate().getYear() it returned 120!!!
I tried to see if I can access it as an array, [index], it returned null
I tried to parse it to Date(), but I couldn't get use of it too.
Is there is anyway that allows me to extract only the year from this format.
This is part of the script where i'm trying to fetch the date I'm using.
function GetAttachmentsWithTime() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
sheet.setActiveSheet(sheet.getSheetByName('Sheet1'));
var start = 0;
var end = 10;
var filter = "has:attachment";
var threads = GmailApp.search(filter,start,end);
Logger.log(threads[0].getMessages()[0].getDate())
}
Are you using the V8 runtime?
If so, see this migration guide. It says:
In the V8 runtime, Date.prototype.getYear() returns the year minus
1900 instead as required by ECMAScript standards.
So emails from the year 2020 would return 120 (i.e. 2020 - 1900 = 120).
To fix this, use .getFullYear():
When migrating your script to V8, always use
Date.prototype.getFullYear(), which returns a four-digit year
regardless of the date.

Using Google Forms, need script to turn form off and on daily, and to clear weekly

I need to:
Set the form to "Not accepting responses" every weekday at 7:16 am
Then set the form to “Accepting responses” every weekday at 5:30 am
Clear all responses from the form and the form spreadsheet on Friday at 2:00 pm
I have no experience with writing scripts. This is for a teacher sign-in sheet for a public high school.
Any help is greatly appreciated!
Unfortunately, StackOverflow isn't here to write your code for you, so you won't receive an answer that you can copy/paste and get to work. The community will instead assist you with any specific roadblocks that you encounter with your code (If they can).
However, you'll be able to achieve this with the Form Service, specifically, the '.setAcceptingResponses()' method. You'll also need the Spreadsheet service with the '.clear()' method to empty the sheet.
You'll find the time triggers are the easiest way to set when the form becomes active and inactive again, however, you've mention very specific times that this needs to go offline and online again (7:16 am and 5:30 am, but only on weekdays, and 2PM to clear the sheet on Fridays), but Google Apps script time triggers can't be set down to the minute (Note the triggers explanation about the time being randomized).
An alternative would be to write a function that checks the time, have that function run every minute, and if the time = 2PM on a Friday then clear the sheet etc.
have you checked out formLimiter by New Visions Cloud Lab?
http://cloudlab.newvisions.org/add-ons/formlimiter
The description is:
formLimiter automatically sets Google Forms to stop accepting responses after a maximum number of responses, at a specific date and time, or when a spreadsheet cell contains a specified value.
Great for time-bound assignments, event registrations with limited seats, or other first-come, first-served signup scenarios.
I was able to write a short script and set a trigger, I named my form "Play"
Here is the script:
function limitDays() {
var form = FormApp.getActiveForm();
var lastDay = 21;
var currDate = new Date();
var dayOfMonth = currDate.getDate();
if (dayOfMonth > lastDay) {
form.setAcceptingResponses(false);
} else {
form.setAcceptingResponses(true);
}
}

How to get the last day of the current month in DataStage?

I have explored all the functions avialable in the trasformer, but could not found the exact function to get the last day of current month by passing date in same default format i.e. yyyy-mm-dd.Please help me in this regard.
Field("31|28|31|30|31|30|31|31|30|31|30|31", "|", MonthFromDate(InLink.dateVar))
It is more precise to establish the first day of next month then use DateFromDaysSince function to establish the day before. I created an integer(6) stage variable which contained century and month+1 from source link e.g. 201410
DateFromDaysSince(-1, StringToDate(svIHBKPR, "%yyyy%mm") : "%yyyy-%mm-%dd")
There is a transformer function called DaysInMonth.
Example: DaysInMonth(“2017-01-23”)= 31

Looking for Function or tips to extract Image Access Date and time in matlab

I have an array of images in an folder,and i would like to read them in the order they copied in the folder i.e. for example there are three images if 1st image copied at 7.15 PM second at 7.45PM and third 7.55PM, i would like to read image which copied first in my folder in terms of time and date.? so how to sort image in that order? have any idea.
On the other hand,if right click on any image,and go to proporties,you will find three types of date i.e. Created date and time, modified date and time and access date and time. i would like to extract the access date and time of any image in matlab? how to do that? pls guide.
I am not sure if there is a way to find the atime with a MATLAB function, you might have to do a system call. On most unix-like systems it would look something like this.
>> [status result] = system('ls -trlu')
I don't know if it's possible to get the "access" date, but you can get the "modified" date with the dir function. By doing:
d = dir('directory');
time = d.date;
You then need to extract the relevant information from the string output of d.date and sort it accordingly.