Dynamic Date and Time Filter: After 5:00 PM In Previous Day - powerquery

I am trying to creat a filter that will pull every account that has been set up after 5:00 PM from the previous day. The date and time exist in the same row. I have created a filter that works for the day but the next day, it pulls for two days. For example, here is what it looks like right now:
= Table.SelectRows(#"Sorted Rows", each [Driver ID] > #datetime(2021, 12, 29, 17, 0, 0))
I have tried changing it to the following so it would dynamically change as the days pass:
= Table.SelectRows(#"Sorted Rows", each DateTime.From([Driver ID]) > Date.AddDays(DateTime.From(Driver ID), -1))
But when I do this I get the following error:
Expression.Error: We cannot convert the value #datetime(2021, 12, 30, 0, 5, 0) to type Function.
Details:
Value=12/30/2021 12:05:00 AM
Type=[Type]
I have made sure the column type is in Date/Time format but that doesn’t seem to help.
Has anybody ran into this issue and know a good solution?

try
= Table.SelectRows(#"Sorted Rows", each Date.IsInPreviousNDays([DriverID], 1) and Time.From([DriverID])> #time( 17, 0, 0))

Related

Micropython: How to use utime.mktime() without knowing the weekday/yearday?

I'm trying to convert an ISO time string like '2021-05-11T18:21:35Z' to an int (seconds from epoch), which mktime() does, except it seems strange to me that it requires the weekday and yearday as part of the argument. In general, it seems unlikely that you would know this, and in my situation I don't.
Obviously in python this is doable with things like datetime, but in uPython these don't exist and I haven't seen a non-external-library way to do this.
Much like with regular Python, the values of weekday and yearday are ignored (they get computed from the other values and are only accepted so that you can pass mktime the tuple returned by e.g. localtime).
You can run:
MicroPython v1.14 on 2021-03-07; ESP module with ESP8266
Type "help()" for more information.
>>> import time
>>> res = time.mktime((2021, 5, 11, 18, 21, 35, 0, 0))
>>> res
674072495
>>> time.localtime(res)
(2021, 5, 11, 18, 21, 35, 1, 131)

Different results parsing the same date in Windows and Linux

We're using pyspark to parse a dataset containing date columns converted to an UTC timestamp with a code that looks like this:
from datetime import datetime
from pyspark.sql import SparkSession
from pyspark.sql.functions import col, to_timestamp, to_utc_timestamp
session = (SparkSession
.builder
.appName('test_spark')
.master('local[*]')
.config('spark.sql.session.timeZone', 'UTC')
.getOrCreate())
date_df = session.createDataFrame([{'date': '2017-10-29'}])
result_df = (date_df
.withColumn('date', to_timestamp(col('date')))
.withColumn('date', to_utc_timestamp(col('date'), 'Europe/Madrid')))
expected_df = session.createDataFrame([{'date': datetime(2017, 10, 29, 0, 0)}])
print("Expected")
print(expected_df.collect())
print("Result")
print(result_df.collect())
In Linux, this code prints (Spark logging omitted):
Expected
[Row(date=datetime.datetime(2017, 10, 29, 0, 0))]
Result
[Row(date=datetime.datetime(2017, 10, 29, 0, 0))]
In Windows 10, however, the output is:
Expected
[Row(date=datetime.datetime(2017, 10, 29, 0, 0))]
Result
[Row(date=datetime.datetime(2017, 10, 29, 1, 0))]
As you can see, in Windows the date parsed have 1 hour more than the result in Linux.
I have tested this with both OpenJDK JRE and Oracle JRE (always version 8) but the result is the same.
What the hell is happening here? If I modify the year or the month of the dates, the "bug" no longer happens, looks like it only appears in 29 October of 2017, what makes this day so special?

Laravel date input format validation

Is it possible to validate date input to name of day followed by a comma, then the day of the month, then the month and finally the year in full? eg Sunday, 31 December 2017
You can use the date_format validation rule with a custom defined date format string:
'some_date' => 'date_format:"l, j F Y"',
Yes, but you have to make your own custom validation function :)
More details you can find here:
custom validator
You can easily download Carbon package from packagist.org
and then use every format you want.
For example :
$dt = Carbon::create(1975, 12, 25, 14, 15, 16);
echo $dt->toDayDateTimeString(); // Thu, Dec 25, 1975 2:15 PM
You can Use Core PHP like this:
$date = '2018-01-01';
echo date('l, j F Y', strtotime($date));

Kendo.toString() returns wrong value for date parse

Hi all I am using kendo library in my page. I am parsing a date to get the month using the below code
kendo.toString(new Date(2000, 1, 1), "M")
and '
kendo.toString(new Date(2000, 1, 1), "MM")
but the result shows me "01 February" and "02" respectivly.
what documentation says is
"M" - The month, from 1 through 12.
"MM" - The month, from 01 through 12.
But I am not sure why the month is going for feb instead of Jan. Any help appreciated.
It is correct! Check Date documentation here
Months in JavaScript are 0 based which means that month 0 is January. In KendoUI "MM" format is the number of the month in 1 base (1 for January).
So the problem is that when you do Date(2000, 1, 1) you are saying February 1st, 2000.

How to find the dates which are there in a week or month till date

How to find the dates which are there in a week or month till date.
days_for_week should return 19,20,21 (assuming current date is 21st)
days_for_month should return 1..21 (assuming current date is 21st)
For the first, you could use Time.now.wday to get the current week day, then minus that will give you the date of beginning of this week.
For the second, it's much simpler, every month begin with 1st, right?
Assuming I'm reading your question correctly...
The second is simple:
def days_for_month
1..Date.today.day
end
The first requires a little algorithm to work back to Saturday:
def days_for_week
days = []
day = Date.today
until day.saturday?
days.unshift(day.day)
day -= 1
end
days
end
Active support provides a lot of useful methods like at_beginning_of_week, at_end_of_week, at_beginning_of_month etc ..
> Date.today.at_beginning_of_week
=> Mon, 20 May 2013
For this particular case, you could do
> (Date.today.at_beginning_of_week..Date.today).map &:day
=> [20, 21]
Similarly
> (Date.today.at_beginning_of_month..Date.today).map &:day
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]
or simply
> 1..Date.today.day

Resources