how to get current date and time in jaggery js? - wso2

I am working in wso2 data analytical server. I'm using query to get data based on timestamp but I have given time stamp manually. Please tell me how to get current date and time together in milliseconds in jaggery js ?

var currentDate = new Date();
Math.round(Date.parse(currentDate) / 1000);
var end = Date.parse(currentDate) // Converting in Timestamp

You can call java within jaggery. So these should work.
var milis = java.lang.System.currentTimeMillis();
var date = new java.util.Date().toString();

Related

Power Bi DAX - Calculating Workingdays from a past period

I´m really struggling about the following problem, searched a lot, tried a lot but still I´m not able to achieve my goal. I really hope, that someone can help me out with this.
Situation
I´ve created a meassure:
Measure =
VAR selYear = SELECTEDVALUE('Stats Param LindyCalendar'[Date].[Year])
VAR selMonth = SELECTEDVALUE('Stats Param LindyCalendar'[Month])
VAR selDay = day(now())
VAR enddate = DATE(selYear, selMonth, selDay)
VAR CurWorkingDay =
COUNTROWS(
FILTER(
FILTER('Stats Param LindyCalendar', 'Stats Param LindyCalendar'[Date].[Date] <= enddate),
'Stats Param LindyCalendar'[WorkingDay_YN] = -1))
RETURN CurWorkingDay
There are three slicers. The first one is based on Country-Table which has correct working relationships to all needed tables. It just filters the Country.
The second slicer is based on 'Stats Param LindyCalendar'[Date].[Year].
The last one is based on 'Stats Param LindyCalendar'[Date].[Month].
When I play around with the slicer, setting random values, it works fine.
Goal:
I want to get back the CurWorkingDay of the last year.
So I did:
VAR selYear = SELECTEDVALUE('Stats Param LindyCalendar'[Date].[Year])-1
The result is "Blank" in the Card-Visual.
That´s my problem, and I don´t know how to fix that.
Would be great if someone could provide a solution or hint.
Thanks a lot in advance.
Finally I got it.
workingdays_MTD =
VAR selYear = SELECTEDVALUE('Stats Param LindyCalendar'[Date].[Year])-1
VAR selMonth = SELECTEDVALUE('Stats Param LindyCalendar'[Month])
VAR selDay = day(now())
VAR enddate = DATE(selYear, selMonth, selDay)
VAR test =
TOTALMTD(COUNTROWS('Stats Param LindyCalendar'),'Stats Param LindyCalendar'[Date].[Date] = enddate,'Stats Param LindyCalendar'[WorkingDay_YN] =-1)
RETURN test
Power BI marks an error for "'Stats Param LindyCalendar'[Date].[Date] = enddate," but it works anyway...

Reduce a time stamp to its date

I am trying to compare current date with report date. The report date comes in this format: "2022-05-30 00:00:00.000000", whereas the current date I want to be in YYYY-MM-DD.
How can I either change the format, or strip the clock time from the timestamp?
var moment = require('moment');
var currentDate = moment().format("YYYY-MM-DD")
const jsonData = pm.response.json();
let date = (jsonData['data'][0]['date'])
pm.test("Fresh data is available", function () {
pm.expect(date).to.eql(currentDate);
});
As the datatype of the Date is string so you can use .substring() to extract only the portion you want. And in case of date, you want first 10 characters, i.e.,'2022-05-30' instead of '2022-05-30 00:00:00.000000'.
So you can use : jsonData.data[0].date.substring(0,10)

How can I create a list in Google App Script to be used in an email from a range of cells

I am learning Google Apps Script so if there is a simple solution to my question, thanks for reading this question.
I have been able to successfully use a script to send individual emails for each row from a range of cells in a sheet. This is the script that does this. This sends an email to an individual if they have been assigned a task. The task owner can receive multiple emails
var templateText = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Code and Functions").getRange(1,1).getValue();
for (var i = 4;i<=lr;i++){
var currentEmail = ss.getRange(i,9).getValue();
var currentName = ss.getRange(i,8).getValue();
var currentStatus = ss.getRange(i,11).getValue();
var currentDescrip = ss.getRange(i,6).getValue();
var currentGroup = ss.getRange(i,5).getValue();
var currentNote = ss.getRange(i,7).getValue();
var currentDate = ss.getRange(i,4).getValue();
var currentRef = ss.getRange(i,10).getValue();
var messageBody = templateText.replace("{Name}",currentName).replace("{Task Group}",currentGroup).replace("{Task Descrip}",currentDescrip).replace("{Task Notes}",currentNote).replace("{Create Date}",currentDate).replace("{Status}",currentStatus).replace("{Reference}",currentRef);
var subjectLine = "Task Assigned";
What I would like to do is accumulate the individual tasks for a recipient and send a list in one email. The portion that I need help with is how to declare a variable for the list.
The email is created by declaring var templateText noted above then replacing the values with the declared variable, i.e currentDescrip, currentGroup ... etc. These variable are single cells. I am attempting to declare a range consisting of a variable number of rows and a static number of columns. I don't know how to do this.

It's posible write a dynamic rowkey filter in apache beam for bigtable

I am looking for a way to filter based on current time in a dataflow job.
I have the following code to read from bigtable but I can't find the way to generate a dynamic scanner or a callable function or lamda to be able to pass the date as a search parameter.
RowFilter filter = RowFilter.newBuilder().setRowKeyRegexFilter(ByteString.copyFromUtf8("2020-06-05#.*#")).build();
PCollection<ObjectDto> collection = pipeline.apply("Read",
BigtableIO.read()
.withBigtableOptions(optionsBuilder)
.withTableId("table")
.withRowFilter(filter));
I need something like that
PCollection<ObjectDto> collection = pipeline.apply("Read",
BigtableIO.read()
.withBigtableOptions(optionsBuilder)
.withTableId("table")
.withRowFilter(RowFilter.newBuilder().setRowKeyRegexFilter(
new SerializableFunction(){
Date d = new Date();
return DateFormat.getDate(d) + "#.*#"+DateFormat.getTime(d);
}
));
Please note that currently the BigTableIO.Read class only supports a ValueProvider to specify either the ProjectId, InstanceId or the TableId. This allows creating a template and changing these parameters dynamically; however, it's currently not possible to pass a RowFilter object in this way.
However, if you are running your pipeline without a template, you can create the Date RowFilter for your use case like this:
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String currentDate = dateFormat.format(date) + "#.*#";
RowFilter filter = RowFilter.newBuilder().setRowKeyRegexFilter(ByteString.copyFromUtf8(currentDate)).build();
And later, pass it to your pipeline:
pipeline.apply("Read",
BigtableIO.read()
.withProjectId("<PROJECT_ID>")
.withInstanceId("<INSTANCE_ID>")
.withTableId(“TABLE_ID”)
.withRowFilter(filter));
In this way, every time you run your pipeline, the filter will be created with the current date.

Mongoose/MongoDB regex find query using variable

I'm trying to perform a find query in mongoDB (using the mongoose framework with nodejs and express) using a regex expression based on a variable. I'm partially able to query correctly using a static string hard-coded into the code but I need to perform the query using a variable who's value is constantly changing.
The query uses three fields (author, date and updated date) and should go through all documents in a scheme and find all documents where 'date' or 'updated date' is like the variable currentDate (always formatted as YYYY-mm-dd) and where author is authorname.
The main issue is that mongoDB stores the dates with ISO format. On execution the string variable (currentDate (YYYY-mm-dd)) is formatted to ISO which leads it to only "hit" documents with time 00:00.000Z as ISO formats 2015-09-17 to be 2015-09-17 00:00:00.000Z (not taking timezone into consideration).
The query:
var currentDate = yyyy-mm-dd;
Scheme.find({$and:[{'local.author': author},
{$or: [{'local.date': new RegExp(currentDate)},
{'local.updated_date':new RegExp(currentDate)}]}]}
I've also tried with the $gte and $lte variables (where $gte = date today and &lte = date tomorrow (00:00)) but I couldn't get it to work, I met the wall trying to perform the regex.
I hope there is a brilliant regex expert out there who can help, thank you! :)
I figured it out without all the complexity.
var tomorrow = new Date();
var today = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
tomorrow.setHours(0,0,0,0);
today.setHours(0,0,0,0);
Scheme.find({$and:[{'local.author': author},{$or: [{'local.date': { $gt: today, $lt: tomorrow } },{'local.updated_date':{ $gte: today, $lt: tomorrow }}]}]}