How to get network days by subtracting from current date and older date on Jasper soft studio? [duplicate] - postgresql

This question already has answers here:
Calculating Time and Date difference
(1 answer)
How to create a single expression displaying time difference between two Date's as years, months, days, hours, minutes, seconds
(1 answer)
Closed 2 years ago.
I need to find net workdays by subtracting from older date from today ?
Ex:Today Date is 7/14/2020 and older date is some 7/14/2019.
Expected result = 365.

The expression is extract(days from now() - <older date column>).
My recommendation is to have the database server perform this calculation for you by adding the expression to the select list in your query. If you prefer to do this with scripting after Jaspersoft has retrieved the data, then I cannot help you there.

Related

MDX Get Sales starting from 2 years ago to today

I'm trying to make a dynamic report that pull sales starting from the first day of the fiscal year 2 years ago up to today and rolls forward with each new fiscal year. Our fiscal years don't line up with calendar years.
I have little MDX experience and am still learning.
So it should look at todays date, get the current fiscal year, subtract 2 years from it and then pull sales starting from that year up to today.
I had some difficulty just trying to get the date working correctly as I was getting errors however the below query now pulls yesterdays sales for me. I assume I need to reference [Date].[Year] as well, but I don't know how to use it to get my desired results.
SELECT
NON EMPTY
{ [Measures].[Gross Margin Percentage],
[Measures].[Gross Margin Value],
[Measures].[Sales Value],
[Measures].[Sales Units] }
ON COLUMNS
FROM IMR
Where
{StrToMember("[Date].[Date].&" + Format(CDate(now()-1), "[yyyy-MM-ddT00:00:00]"))}
If you'd like the results to be across a range of dates then try StrToSet in your WHERE clause and construct in a similar way to what you are doing.
You currently have this:
Where
{StrToMember("[Date].[Date].&" + Format(CDate(now()-1), "[yyyy-MM-ddT00:00:00]"))}
Here is an example for 2 days which you can adapt to your needs:
Where
{StrToSet(
"[Date].[Date].&" + Format(CDate(now()-3), "[yyyy-MM-ddT00:00:00]")
+ ":"
"[Date].[Date].&" + Format(CDate(now()-1), "[yyyy-MM-ddT00:00:00]")
)}

How to determine the number of days in a month based on Hindu Calender(Vikram Sambat)?

My client wants to work in Nepal's Official Calendar- Hindu Calendar (Vikram Sambat). Currently i am using JQuery Ui selector which is static one. In application I need to find the number of days between two dates which are in Vikram Sambat Format; Now, I need to convert Nepali date to English and find the number of days.
And most awkward thing is, general convention of converting date
algorithm could not work perfectly for too old dates like 1960's and
upcoming dates.
By tallying I found that with in 60 years there were only 14 leap years in Vikram Sambat format, actually there must 15 leap years according english date, and number of days in a month also varying year to year some time having 31 some time 32.
I don't want to make use of array for this purpose, i want to know the logic that could determine the number of days in a month.
One of the general convention is Nepali Date to English Date: Subtract - 56 Years - 8 Months - 16 Days

mongodb Get the difference of days from dates having different years

I am trying get the difference of days between two dates having different years. Like difference of days between 2015-12-26 and 2016-05-16.
In SQL I would get this below code.
DECLARE #s DATE ='2015-12-26',#t DATE ='2016-05-16'
SELECT DATEDIFF(N,#s,#d)
Can someone help me to convert this SQL Code in mongodb?
Since mongodb gives the difference in milliseconds, I have calculated the milliseconds for each day and divided with difference of milliseconds between two dates. See below example for reference:
>var s =ISODate("1996-12-31"), t=ISODate(), diff = Math.round((t-s)/(1000 * 3600 * 24))
>print(diff)
7140

Google Spreadsheets - Determining years since date value in another cell

I have cells with date values formatted as DD/MM/YYYY. What I need is to use that value to determine the number of years that have passed since that date as of Jan 1st of the current year.
For example.
4-4-2010 - the value I should see is 3 since only 3 years had passed as of Jan 1st 2014.
But when I open the spreadsheet next year on Jan 2nd it should show 4 since another year will have passed.
I don't need to see months or any increments of years. Just a whole number.
DD/MM/YYYY isn't really supported as a date format by Google Sheets (at least from what I've seen, correct me if I'm wrong. How can you identify if something is DD/MM/YYYY or MM/DD/YYYY when neither DD or MM is > 12?). But since all you're trying to do is get the number of years since a certain year, all you have to do is extract the year from the cell you're looking at and subtract that from the current year.
Assuming the date you using is in cell A1:
=year(now()) - year(A1)

How to get days in between two dates in jasper reports [duplicate]

This question already has answers here:
How to create a single expression displaying time difference between two Date's as years, months, days, hours, minutes, seconds
(1 answer)
Calculating Time and Date difference
(1 answer)
Closed 4 years ago.
I have two dates, one is assign_date (date assigned) and the other one is complt_date (date completed). I have to get the number of days in between the two dates.
DATE ASSIGNED : 04-27-2012
DATE COMPLETED: 04-27-2012
THUS DAYS : 0
NOT COMPLETED (AS OF 03-13-2013)
DATE ASSIGNED : 04-20-2012
DATE COMPLETED:
THUS DAYS : 327
You can do this at the query level, this could be more easier.
For MySQL database there is a function called DATEDIFF:-
ex:- SELECT DATEDIFF(complt_date,assign_date) AS DiffDate