SharePoint custom list date and time validation - date

I have a custom list that I'm trying to restrict data entry for valid day of week and time.
My current column validation works for day of week being Monday, Wednesday or Friday. It looks like this:
=CHOOSE(WEEKDAY([Requested date for approval]),FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE)
I'm trying to figure out the syntax to add that it also has to be between 8 am and 12:00 pm on those days.
Any help would be greatly appreciated.

You would use an AND statement to include a second criteria
=AND(CHOOSE(WEEKDAY([Requested date for approval]),FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE),
AND(
[Requested date for approval]-INT([Requested date for approval])*24 >= 8,
[Requested date for approval]-INT([Requested date for approval])*24 <= 24
)
)
I confess, I've never heard of the CHOOSE function, but the time calculation is based on the information at Microsoft
Convert times
To convert hours from the standard time format to a decimal number, use the INT
function.
Column1 Formula Description (possible result)
10:35 AM =([Column1]-INT([Column1]))*24 Number of hours since 12:00 AM (10.583333)
12:15 PM =([Column1]-INT([Column1]))*24 Number of hours since 12:00 AM (12.25)
EDIT
To calculate the day of the week, you can use the TEXT function to return the day of the week (i.e. Monday)
=TEXT(WEEKDAY([ColumnName]), "dddd")
It won't be pretty, but you can use a series of AND logical operators
=AND(
TEXT(WEEKDAY([Requested date for approval]), "dddd") = "Monday",
AND(
TEXT(WEEKDAY([Requested date for approval]), "dddd") = "Wednesday",
AND(
TEXT(WEEKDAY([Requested date for approval]), "dddd") = "Friday",
AND(
[Requested date for approval]-INT([Requested date for approval])*24 >= 8,
[Requested date for approval]-INT([Requested date for approval])*24 <= 24
)
)
)
)
Posting Working Solution
=IF(
AND(
CHOOSE(
WEEKDAY([Requested date for approval]),FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE
),
([Requested date for approval]-INT([Requested date for approval]))*24>=8,
([Requested date for approval]-INT([Requested date for approval]))*24<=12
),
TRUE
)

Related

Wrong day when using day()-formula with format - PowerBI

I'm trying to find out the weekday i.e Mon, Tue, Wed etc. from a date-range formatted as yyyy mm dd
I tried to use the formula format(day(Date Table),"ddd"), but the weekday is wrong. In my example, the output of 2020.01.01 gives Sunday, but it should be Wednesday.
I think your formula is wrong:
Instead of
format(day(Date Table),"ddd")
Use
format(<Target Table>[<date column>],"ddd")
I.e. Omit the DAX DAY call. This is resulting in the day of the month (1..31) being passed to the format function.
When you use the DAY function in DAX, it returns the day of the month (1 through 31).
Thus DAY ( DATE ( 2020, 1, 1) ) = 1 which means you're trying to format the number 1 as a date. Integers are interpreted as days since 1899/12/30 when treated as a date, so 1 corresponds to 1899/12/31, which happened to be a Sunday. Thus FORMAT(1, "ddd") = "Sun".
There's no reason to get DAY involved here. You can simply write
Day = FORMAT ( 'Calendar'[Date], "ddd" )

Subtracting 1 ISO 8601 year from a date in BigQuery

I'm trying to manipulate a date value to go back in time exactly 1 ISO-8601 year.
The following does not work, but best describes what I want to accomplish:
date_add(date '2018-01-03', interval -1 isoyear)
I tried string conversion as an intermediate step, but that doesn't work either:
select parse_date('%G%V%u',safe_cast(safe_cast(format_date('%G%V%u',date '2018-01-03') as int64)-1000 as string))
The error provided for the last one is "Failed to parse input string "2017013"". I don't understand why, this should always resolve to a unique date value.
Is there another way in which I can subtract an ISO year from a date?
This gives the corresponding day of the previous ISO year by subtracting the appropriate number of weeks from the date. I based the calculation on the description of weeks per year from the Wikipedia page:
CREATE TEMP FUNCTION IsLongYear(d DATE) AS (
-- Year starting on Thursday
EXTRACT(DAYOFWEEK FROM DATE_TRUNC(d, YEAR)) = 5 OR
-- Leap year starting on Wednesday
(EXTRACT(DAY FROM DATE_ADD(DATE(EXTRACT(YEAR FROM d), 2, 28), INTERVAL 1 DAY)) = 29
AND EXTRACT(DAYOFWEEK FROM DATE_TRUNC(d, YEAR)) = 4)
);
CREATE TEMP FUNCTION PreviousIsoYear(d DATE) AS (
DATE_SUB(d, INTERVAL IF(IsLongYear(d), 53, 52) WEEK)
);
SELECT PreviousIsoYear('2018-01-03');
This returns 2017-01-04, which is the third day of the 2017 ISO year. 2018-01-03 is the third day of the 2018 ISO year.

Given an ISO 8601 week number, get date of first day of that week in LibreOffice Calc spreadsheet

LibreOffice Calc spreadsheet offers a function ISOWEEKNUM to return the standard ISO 8601 week number of the specified date.
I want the opposite.
➠ Given a standard week number, give me the date of the first day of that week (the Monday date).
Passing integers is acceptable. Also nice if able to pass a string in standard format.
Like this:
DATE_OF_ISOWEEKNUM( 2017 , 42 ) ➝ date of Monday of week 42 in week-based year 2017
DATE_OF_ISOWEEKNUM( "2017-W42" ) ➝ date of Monday of week 42 in week-based year 2017
Ideally, I would be able to pass a number 1-7 for Monday-Sunday to specify the day-of-week for which I want a date. Something like this:
DATE_OF_ISOWEEKNUM( 2017 , 42 , 1 ) ➝ date of Monday of week 42 in week-based year 2017
DATE_OF_ISOWEEKNUM( "2017-W42-1" ) ➝ date of Monday of week 42 in week-based year 2017
DATE_OF_ISOWEEKNUM( 2017 , 42 , 7 ) ➝ as above, but Sunday
DATE_OF_ISOWEEKNUM( "2017-W42-7" ) ➝ as above, but Sunday
Example:
Formula:
=DATE(B$1,1,$A4*7)+(2-WEEKDAY(DATE(B$1,1,$A4*7)))-7*(ISOWEEKNUM(DATE(B$1,1,1))=1)
Calculate the date of day (weeknumber * 7) in the year.
Correct the day to be weekday Monday.
Correct to 7 days before, if the first day of the year is in the
first ISO weeknumber.

DateDiff not available on Access 2013

I am trying to use the so called DateDiff function to subtract the End Date from the Start Date and obtain the numbers of days apart.For example:
10/11/1995 - 7/11/1995 = 3 (extract the 'dd' from DD/MM/YYYY format)
As date values are double with the integer part counting for a day, you can use this simple expression:
[Due Date]-[Start Date]
or, for integer days only:
Fix([Due Date]-[Start Date])
That said, you should a query for tasks like this.

Powerbuilder Date Math

How do I subtract 30 days from a date in PowerBuilder?
I have the following code that returns today's date in a parameter, but I need today - 30 days:
dw_1.setitem(1, "begin_datetime",
datetime(today(), Now()))
you're probably looking for the RelativeDate function. Unfortunately, it takes a Date and not a DateTime as a parameter, but we can get around that:
dw_1.setItem(1, "begin_datetime", DateTime( RelativeDate( today(), -30), Now() )