AdehabitatLT and ltraj object: how to extract mean distance between relocations? - adehabitathr

I have an ltraj object , I would like to extract the mean distance for day and the mean time for day. The date is stored as "("%d/%m/%Y %H.%M.%S"), anyway I just need the relocations that occured during the same day. I have tried the function aggregate:
a=aggregate(traj[[1]]$dist, by=list(traj[[1]]$date,"%d/%m/%Y"), FUN=mean)
I received the following error message:
Error in aggregate.data.frame(as.data.frame(x), ...) :
arguments must have same length
I don't know how to ignore hour, minute and seconds and take in consideration just the year, month and day.

Related

Netsuite compare 2 datetime in saved search criteria

I would like to send an email if my URL is expired.
For that, I have created a saved search and a custom transaction field.
My goal is to show the transaction record in the saved search, from the moment the date is expired.
I tried with formula date but it return only if the date is before today. But it can happen that we are the same day and that the url is expired for 1min or 1hour.
Ex: Today = 13/09/2022 3:00 pm and expiration date is 13/09/2022 2:59 pm
So I tried with Formula numeric to do:
{customfield} - {today} is less than 0
But Netsuite return an unknown error.
So I tried:
TO_CHAR((NVL({customfield},{today})-{today})) is less than zero
But it return this kind of value so it's always zero
+000000000 20:57:33.000000
or
-000000000 02:26:33.000000
or
+000000000 00:00:00.000000
How can I do to send an email when the DateTime from my custom field is in the past?
The formula type you select specifies the data type for the result returned. When you select "Formula (Date)" (formuladate) or "Formula (Date/Time)" (formuladatetime), NetSuite will convert the returned difference into a time interval formatted as a date or timestamp. For numerical comparison, use "Formula (Numeric)" (formulanumeric) instead.

Can I plot/filter just the peak value per day in excel

I have a dataset which is amount (parts per million) against time (every minute)
I need to find the peak for each day, so that I can plot that against other data, I can manually do this using =MAX( but I have a lot of data points and I am sure there is a better way
Many Thanks for the help
I don't know where and how you want show this data, but, if you want get a max value amount per day, you can try add an array formula, like that:
=MAX(IF($COL_DATES = $DAY, $COL_VALUE, 0))
Replace $COL_DATES to your column of day date, replace $DAY to value of day what you want get max value and replace $COL_VALUE to your column of values.
After press CTRL + SHIFT + Enter

Converting number to time in excel - variable number of digits

I have a report which is downloaded from a Warehouse Management System.
On this report there is a time column which unfortunately puts the time into a string of numbers that can be anywhere from 5-8 digits long.
I.e.
22434900 = 22:43:49:00 with 22 being the hour, 43 the minutes, 49 the seconds.
2480000 = 02:48:00:00 with 2 being the hour, 48 the minutes etc.
54300 = 00:05:43:00
The 00 on the end (milliseconds) doe not change in each number so is quite irrelevant.
Is there an easy way to format the text in these cells so it shows as a time as oppose to a number?
Thanks in advance.
I know I'm late, but here's an alternate solution:
=TIMEVALUE(TEXT(A1/100,"00\:00\:00.00"))
Again, as mentioned in Jerry's answer, you'll need to use cell formatting of hh:mm:ss.00
You can use TIME with some math functions:
=TIME(INT(A1/1000000),MOD(INT(A1/10000),100),MOD(A1/100,100))
TIME takes 3 parameters: hours, minutes and seconds.
To get the hours, I'm dividing by 1000000, then INT rounds it down to the closest integer.
To get the minutes, I'm first dividing by 10000, but there is still the hours in that result. So I use MOD (which gives the remainder when a number is divided by another number). In the first example, the division gives 2243, and the remainder when dividing this by 100 is 43, which is the number of minutes I'm looking for.
To get the seconds, I divide the number by 100 and similar to the minutes, I use MOD to remove the minutes and hours parts. I am not using INT here in case there are milliseconds, which will be kept using this formula.
Also note that I am using the formatting hh:mm:ss.00, because excel complains if I try using hh:mm:ss:00.
For your Warehouse Management System query you may want to try something like this:
• Taking the 6 digit numeric time and making this into a string that the time function can handle
• Using the digits function to avoid issues with varying lengths of data (i.e. 64512 vs 1113012)
• Use the function Time over this string to return the value (this way we can add hours or minutes as the example below)
Here is an example to experiment with this and :
select MyTimeField
, time(int(MyTimeField/10000) || ':' ||
substring(digits(MyTimeField),3,2) || ':' ||
substring(digits(MyTimeField),5,2))
from MyTable where MyCompany = 1 and MyInvoiceDate = Current_date

Strange date behavior with mongoose

I have a document in my database that gets displayed like this when inspected with MongoDB Compass:
Now I have experimented a bit with it on the command line:
I understand that getMonth returns one because they range from 0 to 11, but why does getDay return numbers that to me appear have no relation whatsoever with the saved date?
getDay() returns the day of the week (from 0-6).
So wednesday will be 2.
Try getDate() to return the day of the month.
if you look documentation for getDay() you will find out that:
The getDay() method returns the day of the week (from 0 to 6) for the
specified date.
I think that on your computer culture week starts on Sunday. So you are getting numbers that you are gettings.
Also I bolive that you wanted to use getDate() method:
The getDate() method returns the day of the month (from 1 to 31) for
the specified date.

Excel Convert text to timestamp

I have the following text timestamp in cell A1. 22-OCT-13 03.40.00.000000000 AM. In B1 I have the following formula: =TIME(HOUR(MID(A1,11,2)),MIN(MID(A1,14,2)),SECOND(MID(A1,17,2))).
It yields 12:40 AM. The hour function returns zero, but the minute function works fine. I can't figure out what's up with it.
MIN is the 'minimum' formula that returns the smallest value out of a list of values, not the MINUTE formula.
I think you are not familiar with TIME(), HOUR() or MINUTE().
TIME() takes 'normal' values and converts them into a time value. If you have TIME(H, M, S), H is the number of hours (not a timestamp), M is the number of minutes (not a timestamp either) and S is the number of seconds (yet again, not a timestamp).
HOUR() takes a time value and extracts the hour from it.
MINUTE() and SECOND() are similar to HOUR(). What you probably meant to have is:
=TIME(MID(A1,11,2),MID(A1,14,2),MID(A1,17,2))
When you use MID() you are getting a number, not a timestamp. So, HOUR takes that number, interprets it as a timestamp and return the hour. In your example, the first MID returns 03. In excel, if you convert that to a timestamp, you get 03/01/1900 00:00 (in dd/mm/yyyy hh:mm format) and the hour is thus 0.
EDIT:
By the way, you could use this formula if you want to keep the date and time (not forgetting the AM/PM at the end:
=SUBSTITUTE(SUBSTITUTE(A1,".",":"),":",".",3)*1
The original date/time is almost one that can be understood by Excel. Replace all . with : and then replace the 3rd (last) : by . and multiply by 1 to tell Excel to convert that to a number. Just format the result as time and that should do it.

Resources