How to initialize and compare dates (such as production/ expiration date of a product) in AnyLogic? - anylogic

I would like to create two variables as the production date and expiration date for my agent "Product" in AnyLogic and then compare the expiration date to the current date of the model to find out if it's expired.
I modeled the variables as Date:
Date productionRDate;
Date expirationRDate = addToDate(productionRDate, DAY, 30);
and compare expirationRDate to the current date like this:
differenceInCalendarUnits(DAY, agent.expirationRDate, date()) > 0
and initialized productionRDate as in the image below. But it has an error that says:
initialization and the error
Any suggestion on what should I do?
Thanks a lot.

You need to initialize productionDate as well, it is currently empty, so you cannot add to it.
Do something like
Date productionDate =date();
It needs to have a value

Related

Google App Script - how to set date with timezone in AdminReports.UserUsageReport.get()

I'm using Apps Script and trying to extract data from AdminReports.UserUsageReport.get('all', 'the date') (to get classroom last interaction timestamps), but it always comes with records from another day. For example, if I extract from the 5th, the report brings the 6th together, until 7 o'clock in the morning.
The date parameter is a string and in the documentation says the following:
Represents the date the usage occurred. The timestamp is in the ISO
8601 format, yyyy-mm-dd. We recommend you use your account's time zone
for this.
But if the parameter is a string in yyyy-mm-dd format, how am I going to pass the date with the right time zone?
This code not work:
var myDate = new Date(2021,5,5);
var timezone = Session.getScriptTimeZone();
var date = Utilities.formatDate(myDate, timezone, 'yyyy-MM-dd');
var page = AdminReports.UserUsageReport.get('all', date);
How do I use the date correctly?
Thanks a lot.
If the report dates are UTC, then each may first be converted to JavaScript Date objects using
var myDate = new Date('report_date_string');
The second two lines of your code look like they should follow correctly in converting and formatting the Dates to strings in your local time zone.

MS Access: Show string in the date field when empty

I'm looking to have my field show "dd-mmm-yy" when a date is not entered into the field, so members don't get confused and frustrated when they try to put in a date such as 11/12/20 and don't realize it needs to be in day day, month month month, year year format. Is this possible to do through the property sheet?
[date format]
You can set the Format property of the textbox to:
dd-mm-yyyy;;;"dd-mm-yyyy"
though I believe it will add more confusion than help.
Another method for speedy input of dates is shown in my article:
Entering ISO formatted date with input mask and full validation in Microsoft Access

Quicksight datepicker for month only

I'm searching for a way to have month selection and that will serve as startdate and enddate for the date filtering.
I'm building a monthly report on quicksight, I try to use the last 31 days but that give information of multiple months
I already create date picker for those parameters but didn't find any way to limit the value to be the complete month only.
Example : if select the 12 september I desire to get the September values only (from the 1er to the 31th)
Any advice is welcome
Thanks for your help
First, add a new date filter (if you want, e.g., today to be the default you'll need to add a dynamic default against a data set that returns today)
Add a new control (I found naming this to be difficult, perhaps you're better at picking names than I am)
Add a new calculated field that returns 1 if the truncDate of your date field and the truncDate of your parameter are equal, otherwise return 0
ifelse(
truncDate("MM", {date}) = truncDate("MM", ${InMonth}),
1,
0
)
Finally, add a filter that checks where your calculated field is 1 and apply it to all visuals

Using Current Date Time in SAS

I am selecting the data from a table using a date string. I would like to select all rows that have a update time stamp greater than or equal to today.
The simplest way that I can think of is to put today's date in the string, and it works fine.
WHERE UPDATE_DTM >'29NOV2016:12:00'DT;
However, if I want to put something like today's date or system date, what should I put?
I used today(), but it returned all rows in the table. I am not sure if it's because today() in SAS refers to the date 1/1/1960? I also tried &sysdate, but it returned an error message seems like it requires a date conversion.
WHERE UPDATE_DTM > TODAY();
Any ideas? Your thoughts are greatly appreciated!
DATETIME() is the datetime equivalent of TODAY() (but includes the current time). You could also use dhms(TODAY(),0,0,0) if you want effectively midnight (or, for your example above, dhms(TODAY(),12,0,0) to get noon today).

RapidMiner Get Day of the Week

I am using RapidMiner to deal with a dataset that has a timestamp attribute. I am using the Generate Attribute operator to obtain the date from the timestamp:
date = date_parse([vr_timestamp])
However, I need to obtain the Day of the week (Monday, Tuesday, ...).
Any idea of how can this be achieved?
You can use the following within Generate Attributes.
dayofweek = date_str_custom(aDate, "E")
In this case, aDate is an attribute of type Date time and dayofweek is your new attribute.
A full reference to all possible values that control this is given here.