Reduce a time stamp to its date - postman

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)

Related

Filter a list of object using koltin list

I am trying to filter a list of object in Kotlin. The list is defined as List<Temperature> which contain the temperature hour after hour for the next 2 days and the Temperature Object is defined as :
data class CurrentlyEntity (
var time: Long,
var summary: String,
var temp: Float)
The time is a timestamp, so I was able to retrieve it to convert it to a human-readable time and date. I have also been able to extract the lowest temperature using .minBy.
However, I am not able to filter the list to only get the temperature of today and remove any timestamp related to tomorrow.
I was hopy that something like:
listOfTemp.filter { it == DayOfToday }
can help?
Any idea ?
Regards

Power BI Lookup with Duplicates Equation

I have a data set that contains duplicates and i am trying to do the equivalent of a Vlookup from excel. In excel when you use the vlookup function it will just return the first value even if there is a duplicate. The data set that i am working with has a unique 16 character string.
I have utilized some videos, forms, and other resources but no luck. I have used the calculation equation with a first non blank and a filter but i either get an error or returns blank.
https://1drv.ms/x/s!AtrxZbQBYb0LjZtaIkZcn4qsMimwnQ?e=PZbNud
Column = CALCULATE(
FIRSTNONBLANK('Table1'[ID]),
FILTER('Table1','Table1'[Parent]='Table1'[ID]))
You can go with:
Column =
var SampleID = 'Sample Data'[ID]
var EarliestDate = CALCULATE(MIN('Sample Data'[Creation Date]);FILTER('Sample Data';'Sample Data'[Parent] = SampleID))
return CALCULATE(MIN('Sample Data'[Text]);FILTER('Sample Data';'Sample Data'[Parent] = SampleID && 'Sample Data'[Creation Date] = EarliestDate))
Note: it finds the earliest date ann when dates are equal, smallest string
Enjoy!

calculation of differences of dates in Swift 3

I have created 3 outlets for labels,1 action for button and 1 outlet for UIDatePickerView. lblField displays the current date with month, date and year[January 25, 2017] format. lblField2 displays the selected dates by the user after pressing dueDate action. Now, I need to calculate the differences between the current date and selected date i.e (lblField2 - lblField) in lblField3. How can i show the difference value in months and days in Swift3. I need strictly for Swift3 ?
You can use dateComponentsFormatter for that.
let formatter = DateComponentsFormatter()
formatter.allowedUnits = [.month,.day]
formatter.maximumUnitCount = 2
formatter.unitsStyle = .full
lblField3.text = formatter.string(from: Date(), to: datePicker.date) ?? ""
If you want difference with month and day specific that you can use Calendar this way.
let components = Calendar.current.dateComponents([.month, .day], from: Date(), to: datePicker.date)
let dayDifference = components.day!
let monthDifference = components.month!
var date = NSDate().dateStringWithFormat(format: "dd.MM.YYY")
print(date)
15.02.2017
this will be the date formater easy and new single line sytax

how to get current date and time in jaggery js?

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();

jquery datepicker returns wrong year when using date format without year part

I use jquery datepicker (v1.8.20) with the date format set to 'D MM d' which looks like: 'Wed September 12'. When I select different year than the current one from a calendar, the getDate method returns me current year. Moreover, when I open calendar again, both selected day and month are preserved, but the year is changed for the current one. Generally it looks like year is set to current one when the date format does not contain it. Any idea how to fix that?
Datepicker stores value only in input element, so if you don't have a year in format string, datepicker merely doesn't store it. Here one of jquery.ui developers says, that this is not a bug and "Datepicker is only designed to pick a full date".
Anyway, I had the same problem in my project, and solved it by ugly trick, that forces datepicker to store full date:
(function($) {
$.datepicker._selectDateParent = $.datepicker._selectDate;
$.datepicker._adjustInstDateParent = $.datepicker._adjustInstDate;
$.datepicker._adjustInstDate = function(inst, offset, period) {
var fullDate = inst.input.data('fullDate');
if(fullDate && !period) {
inst.drawYear = inst.currentYear = fullDate.getFullYear();
}
this._adjustInstDateParent(inst, offset, period);
};
$.datepicker._selectDate = function(id, dateStr) {
var target = $(id);
var inst = this._getInst(target[0]);
var date = this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay));
inst.input.data('fullDate', date);
this._selectDateParent(id, dateStr);
}
})(jQuery);
I've tested it only with datepicker 1.9.0+ and I'm not sure, that this is a good solution, but it works for me :)