I would like to set coming Thursday on my SharePoint date field as default date.For example whenever I open the form it should display coming Thursday as default date in Any idea what will be the formula ?
If you want the default value to be "next Thursday", then
a) if today is Thursday and you want the default date to be today:
=IF(WEEKDAY([Today]<5),[Today]+4-WEEKDAY([Today]),[Today]+11-WEEKDAY([Today]))
b) if today is Thursday and you want the default date to be next Thursday, not today:
=IF(WEEKDAY([Today]<4),[Today]+4-WEEKDAY([Today]),[Today]+11-WEEKDAY([Today]))
If today is not Thursday, you get "next Thursday" as expected in both cases.
Related
I have a weird situation where I need to make a DueDate to be the following Friday.
So if the date is Monday, March 11th 2019 then the DueDate is Friday March 22nd.
I am able to do this easily with:
TRUNC(Next_Day(FilingPeriod, 'FRI')) + 7 as DueDate
My issue comes when the day is Friday March 15th 2019 ad it should also have a DueDate of Friday March 22nd, instead it has a DueDate of Friday March 29th.
And I get why. I have been looking for a way to simplify this or throw in a check to determine if the current date is a Friday and go from there.
I have looked for a bit and read similar questions but I still can not seem to find it.
Thanks for any help
Just subtract 1 from the date before using NEXT_DAY():
TRUNC(Next_Day(FilingPeriod - 1, 'FRI')) + 7 as DueDate
Get back to Monday, the first day of the ISO week. Then go plus 4, then plus 7 days:
TRUNC(FilingPeriod, 'iw') + 11
On a sidenote: I'd avoid NEXT_DAY whenever possible. The day name depends on the current language setting and NEXT_DAY has no parameter to override this. This renders the function rather dangerous, because it makes a query fail-prone.
I need get Monday of last week E.g
Today is 28/11/18 (wednesday)
I need get 19/11/18 (monday)
I know that I can obtain Monday of the current week with
val monday = DateTime().withDayOfWeek(DateTimeConstants.MONDAY)
I get it!
DateTime().withWeekOfWeekyear(
DateTime().weekOfWeekyear-1)
.withDayOfWeek(DateTimeConstants.MONDAY)
I only have to get the week of the year and subtract one week and that is all
I need to print the last sunday of the year from which adding 7 to it will give me all the sundays of next year.
I have the code to print all sundays for a particular year if i have a start date but i need the user to put the year so that last sunday of the previous year will be generated and 7 will be added to get first sunday of that year and so on till it reaches last sunday of next year
For example input year is 2017 it will check the last sunday of 2016 and add 7 to it to get first sunday of 2017 which is 1-1-2017 and it will go on printing all sundays till it reaches 31st december 2017
The function next_day() takes two arguments: a date and the name of a day of the week. It returns the closest "next" day (following the date argument) that matches the given day of the week. So the result is between one and seven days forward. (If you want 'Tuesday' and the input date is a Tuesday, the function returns the date seven days later.)
If you want the last Sunday of a year, it will be between Dec. 25 and Dec. 31. So if you call the next_day() function with the arguments Dec. 24 (!!) and 'Sunday' you'll get what you want.
The result will have the same time-of-day as the date argument, so if you give a date without a time-of-day, so will be the output (which is probably what you want). So:
select next_day(date '2016-12-24', 'Sunday') from dual;
NEXT_DAY(D
----------
2016-12-25
Added: If you take an input from your user, as a bind variable, you can do something like this:
select next_day(to_date(:input_year - 1 || '-12-24', 'yyyy-mm-dd'), 'Sunday') from dual;
If you provide 2017 as input (whatever mechanism your interface has for bind variables), the output will be 2016-12-25 (in DATE data type, so don't ask "in what format" - dates don't have a format!)
Please help me with an Informx SQL query to be run every Friday.
Period: 1st of the Month to the Thursday before the Friday that it is being run on. I can't just choose date ranges as it will be an auto report so the dates needs to update automatically. Is there a way to do this?
You've got two issues: the start of the month and the date of last Thursday. The simplest expression to identify the 1st day of the current month is:
MDY(MONTH(TODAY), 1, YEAR(TODAY))
The way to identify the most recent Thursday is via a CASE statement on WEEKDAY(TODAY). Something like:
CASE
WHEN WEEKDAY(TODAY) < 5 -- (Sunday (0) - Thursday (4))
THEN TODAY - WEEKDAY(TODAY) - 3 -- Calc last Sunday, back 3 days
ELSE TODAY - WEEKDAY(TODAY) + 4 -- Calc last Sunday, forward 4 days
END
Note, you will still run into issues where the 1st of current month is later than the most recent Thursday. But hopefully the examples above will point you in the right direction.
Of course, if you know this report is only ever going to be run on Fridays, then calculating the most recent Thursday is just TODAY -1.
I have two columns called
1ST column Calendar Date:
16/02/2015
2nd Column Previous Day:
Yes
Formula I am currently using:
if([calendar Date])=today-1,"YES","NO").
The 2nd column returns value based on the 1st column.
However , the problem I am getting is when I run the data on monday when we have calendar date (day on friday). So it is showing "NO" as formula only returns data for previous day.
So I want something like this
Only when I run on Monday it should give me if([calendar Date])=today-3,"YES","NO").And all other workdays if([calendar Date])=today-1,"YES","NO")
Can you please help me on this.
If you cell A2 has the calender date then try with below formula.
=IF(WEEKDAY(A2)=6,(IF(A2=TODAY()-3,"YES","NO")),(IF(A2=TODAY()-1,"YES","NO")))
=IF(WEEKDAY(TODAY())=2,IF(TODAY()-3 = A12, "YES", "NO"), IF(TODAY()-1 = A12, "YES", "NO"))
first, identify whether the date today is monday or the other day of the week.
IF(WEEKDAY(TODAY())=2
If today is monday, then you can create the condition that the previous day must be friday [today()-3].
IF(TODAY()-3 = A12, "YES", "NO")
If today is not monday, then create the condition that the previous day is the date yesterday [today()-1].
IF(TODAY()-1 = A12, "YES", "NO")
To disregard weekends and holidays, you will want either the NETWORKDAYS or
NETWORKDAYS.INTL¹ function. Not only can you skip a conventional Sat/Sun weekend but you can add a reference to a list of holidays to be discounted as well. The newer NETWORKDAYS.INTL has a large selection of built-in non-standard 'weekend' formats or you can write your own. e.g. "0000011" is a standard Sat/Sun weekend and "0101000" is a Tue and Thu 'weekend'.
Both NETWORKDAYS and NETWORKDAYS.INTL count the number of days inclusively so you are looking for a value of 2, not 1.
For the following example, I've reset the computer's system date to Tue 19-Jan-2016 (the day after Martin Luther King Day, 2016).
=IF(NETWORKDAYS.INTL([#[calendar Date]], TODAY(), "0000011", Z$2:Z$11)=2, "Yes", "No")
If you wanted to get a little more elaborate, just use the NETWORKDAYS.INTL function with a custom number format of [=2]\Y\e\s;\No;\No. This allows you to retain the actual underlying value of the NETWORKDAYS.INTL formula while displaying Yes or No.
The results from the image above clearly show that both the weekend and holiday were discarded from consideration and that Fri 15-Jan-2016 is considered the previous day.
¹ The NETWORKDAYS.INTL function was introduced with Excel 2013. It is not available in earlier versions.