Date no greater than the current year or next year - date

I need to set a validation rule in Access so that the DateOfArrival is always after the DateOfTheOrder.
I also have to make sure that the DateOfArrival is not set too far away in the future...so it shouldn't be greater than the current year or the following at max (for cases such: order 31 dec 2015, arrival 1 jan 2016).
I've put:
[DateOfArrival]>[DateofOrder] AND [DateOfArrival]<=Year(Date())+1
in the validation rules but if I enter DateofOrder=31/12/2015 and DateOfArrival=01/01/2016 it gives me an error. Can you help me?
The error must be in the second part of the rule.

[dateOfArrival] is a Date, while YEAR(Date()) is an Integer ...
When comparing them, [dateOfArrival] will be considered as a number, being the number of days since the 31/12/1899, and YEAR(date()) will be definitely and always lower than this number.
You should compare YEAR(dateOfArrival) with YEAR(date()))!

Related

how to count week number of month using dataprep

I tried to count week number of month using below code,but I got weird num like -48.(I know my logic is weird lol)
Could you point out the fault of below code to make weeknum of month.
I need sensei's help.
I used Dataprep
WEEKNUM(date)-WEEKNUM(DATE(YEAR(date),MONTH(date),1))
no error , but some values are -48,47......
Your logic is mostly sound, except you're only thinking of WEEKNUM in the context of a single year. In order to have non-overlapping weeks, the week containing January 1 is always week 1 (regardless of the period), so in this case December 29–31, 2019 are all going to be week 1, just like the following 4 days of January will be. It makes sense, but only when you think about it in context of multiple years.
You can work around this for your case by checking the WEEKNUM and MONTH values conditionally, and then outputting a different value:
IF(AND(MONTH(date) == 12,WEEKNUM(date) == 1),53,WEEKNUM(date)) - WEEKNUM(DATE(YEAR(date),MONTH(date),1))
While hard-coding the week number of 53 is a little hacky, the whole point of week numbers is to always have 52 subdivisions—so I don't really see any concerns there.
You may also want to add 1 to the resulting formula (unless you want your week numbers to start with 0 each month).

IBM Watson Assistant: How to get just few numbers with System entities sys-number

I have some Business rule to follow.
I need to request for the user one Year, and currently, I'm using #sys-number to get the Year and other data if need numbers.
I want to know if have some form to get the #sys-number with just 4 digits, like:
Watson: What the year, please? Format example: - 2017
User say: the year is 17 (#sys-number get the 17 fine)
User say: the year is 2017 (#sys-number get the 2017 fine)
I need: ONLY If the user types the 4 numbers from the year, the condition #sys-number[4] //I don't know will get the year correctly and the Conversation will flow.
My condition currently within the node is:
if bot recognizes #sys-number
You could use two predicates:
if #sys-number and #sys-number>1000
The first would make sure that really a number was entered, the second predicate would take care of 4 digits. You could even add another predicate and limit the range of valid years.

RRULE 20 days after every 15th in a month,in icalendar (RFC 5545)?

I'm searching a way to express a situation like this in icalendar: an event happens every month, x days after a given date.
e.g.: 20 days after 15th day in every month. so, it might be 3rd, 4th, 5th,6th( like February )
if bymonthday can be set to 35, it's ok.
But in outlook this won't work.
How to solve this question?
You could perhaps try adding ";BYSETPOS=20" to the rule. The specification shows an example of BYSETPOS when using it with BYDAY, but it is not clear to me how it is handled when using BYMONTHDAY. I don't see another option looking at the spec.
http://icalendar.org/iCalendar-RFC-5545/3-3-10-recurrence-rule.html
http://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html
Sorry, what you want is not possible with a RRULE.
What you want is RRULE:FREQ=MONTHLY;BYMONTHDAY=35. Unfortunately, it's invalid - BYMONTHDAY can't exceed 31.
BYSETPOS won't work either. In RFC 5545, page 43 under BYSETPOS is the following:
"BYSETPOS operates on a set of recurrence instances in one interval of the recurrence rule."
That means you can't get a value beyond the interval. If you use Monthly you are restricted to the one month.
If you want to experiment with some RRULEs try my recurrence rule (RRULE parser) at
http://balsoftware.net/index.php/open-source/rrule-parser/

Matlab- Changing uniques date code values to more manageable data

I have a variable called sentDate which stores the month and day from Nov 27th - Dec 6th.Each day has a number of sentiment ratings that it represents therefore I need to assign unique day codes to each day so I can perform...
allSents(dayCodes==1)
So far I have managed to assign day codes using...
[a,b,dayCodes]=unique(sentDate);
[d,e,allSents]=unique(sentiment);
However the day codes take the last digit on the date e.g 27th becomes 7, 28th becomes 8, etc. I need it so the day codes start from 1 and increase for each day until the 6th of December, therefore 1-11.
Any idea on how I may do this ?
have you tried the datenum function? then subtract off whatever offset to give the appropriate start day number.
For those who may have a similar problem, by specifying stable in as a parameter e.g
[a,b,dayCodes]=unique(sentDate,'stable');
Will specify the daycodes in the same order as in sentDate.

Table Calc - with IF statement? - Tableau

We have YTD data only. I've been trying to get a MTD running across the table.
So I thought I can run a Table calculation type - "Difference From" previous month.
This works well except for the first month of the year.
Jan MTD = Jan YTD NOT Jan YTD less Dec YTD
So January numbers are never right.
Is there a way to say, If month = "Jan" don't perform the table calc?
regards
Gem
You probably have something like
ZN(SUM([YTD])) - LOOKUP(ZN(SUM([YTD])),-1)
Then, for the first entry, LOOKUP() will return null. All you need to do is to return 0 instead, using ZN()
ZN(SUM([YTD])) - ZN(LOOKUP(ZN(SUM([YTD])),-1))
In case you don't know, you need to go to Edit Table Calculation..., then Edit Formula...
EDIT: I understand you have a bigger problem, that is your rolling sum restarts every year. In that case you really need an IF statement, but it is possible to overcome your "it's not always the same starting month" problem. You just need to check if that month is the first in your list or multiple of 12:
IIF(-FIRST()%12 = 0,
ZN(SUM([YTD])),
ZN(SUM([YTD])) - LOOKUP(ZN(SUM([YTD])), -1))
You just have to understand the FIRST() function. It will return the distance from the current position to the starting position. So, if you start in February, in August First() will return -6.
And the modulo operator will guarantee you restart every 12 months
Thanks Inox.
You are correct.
However I was intending more like this:
IIF(min(month([period_date]))=1,
ZN(SUM([YTD])),
ZN(SUM([YTD])) - LOOKUP(ZN(SUM([YTD])), -1))
Since the formula is an aggregate, I had to use "min" for the date. That was my problem using the IIF function, which was not apparent in my question.
This will produce MTD beyond 1 year, When it reaches the second January, it will not subtract Dec YTD.
Only problem I have now though is, if you begin the table on a month other than January... ie Feb.
Feb MTD is not Feb YTD??
(this is another problem, my report is to produce a rolling 12 month)... ie Feb to Jan, Mar to Feb)
So far, I'm just displaying 2 years to get over this, so forcing it to start on January. Not really a solution, but it gets the information across 12 months.