Calculate date difference and return number of days - sql

I need help to calculate the date difference and return number of days.
I used this in rtf template but it didnt work and when i hard code the dates it works!and not sure what is wrong with the data field.
UDRDAILYACTDATEDO this is variable,
UDRFCDDATEDO this is fixed date when the contract starts, and I need to calculate the cumulative days from first chargeable date FCD.
and when i try to calculate the days inside the data set in BI usining numtodsinterval it return the seconds along with the number and couldnt find a way to truncate it.

Related

SQL QUERY: Sum of amounts equal to last day of reporting month & cutoff date is equal to and greater than reporting month

I am trying to ask this question as best as i can so please forgive me inadvance if its not 100% clear.
I have a set of data which shows the date a transaction is processed.
For the same set of data I have the date of cut-off
what i am trying to achieve is finding the sum of transactions where:
Processed in a given month but the cut-off date is on the last day of the reporting month or future dated
e.g.
From the above on May-22 should have 100 and Jun-22 i should have 200 that has not met the original deadline.
Any help on this would be great. I have tried a few solutions but could not make them work

How to adding month to date in and return in Date format in Robot Framework

I try to calculate month.
My Example code: 27/01/2020 + 20 months
Test Date
${PAYMENTDATE} Set Variable 27/01/2020
${PAYMENTDATE} Convert Date ${PAYMENTDATE} date_format=%d/%m/%Y result_format=%Y-%m-%d
${DATE} Add Time To Date ${PAYMENTDATE} 20 months result_format=%d/%m/%Y
log to console ${DATE}
But it not work, Could anyone help please?
In your code you are providing time value in months which is not valid. Unfortunately adding months to the date is not possible using the Robotframework DateTime library. From the DateTime documentation:
time: Time that is added in one of the supported time formats.
You need to provide the time value in one of the possible way e.g. You can provide days.
20 months approximates to 600 days and below code works without problem.
${DATE} Add Time To Date ${PAYMENTDATE} 600 days result_format=%d/%m/%Y
In case you are looking for exact days to be added for 20 months than you need to calculate exact number of days starting from the date you want to add 20 months to and provide it in above code instead of 600 days. You can easily find answers on how to calculate exact days using python like this here.

How to Cast Date to String for Chart with Weekly Groupings in MS Access

I have a simple Access application where I want a chart that shows groupings by weeks from daily records.
I have a query that converts the groups by the week and then displays the week as the first day like this:
WeekBegin: DateAdd("d",-(DatePart("w",[ScoreDate])-1),[ScoreDate])
Thsi gives the Sunday beginning the week correctly. The problem comes when I go to make a chart. The chart Row Source is
SELECT [WeekBegin],Sum([Scores]), (etc...) FROM [query] GROUP BY [WeekBegin];
When I do this the chart treats the bottom axis as a date value and each week is seven days apart making the bars tiny.
I'm sure the date format is the issue because when I make an integer out of the week value it formats how I want:
I can't figure out how to get it to show as a date like "mm/dd" but not treat it as a date and add all those blank days in between. I've tried messing with the axis settings but it doesn't seem to do anything.
Try casting the date as a varchar... use convert to get into whatever display format you want.

How to get days difference between two dates in velocity templates?

I want to get days difference between today's date and a payment due date (next date greater than todays date) using velocity template. If my today date is 12/10/2016(MM/dd/yyy) and payment date is 22/10/2016(MM/dd/yyy),the date difference should be 10. I tried in difference ways, couldn not find the exact solution. Can anybody help me on this?
If you use velocity-tools, you can check the ComparisonDateTool.
$dateTool.getDate() is todays date.
Final statement is like so:
$date.difference($payDate, $dateTool.getDate()).days==10
Make sure you have ComparisonDateTool in tools.xml.
class="org.apache.velocity.tools.generic.ComparisonDateTool"
format="MM/dd/yyyy H:m:s" depth="1" skip="month,week"
bundle="org.apache.velocity.tools.generic.times" timezone="EST"/>

MDX Beginning to Current Date Sum

This is regarding calculating the sum for a set of values starting from the date a measure has entries till the current date.
So far what I could find was the YTD function. This limits the aggregation capability till the current date beginning from the first day of the year. But what my requirement is to start the calculation from the first value, this could be in the last year or may be two years before.
Eg:
Date-----------Value
11/9/2010-----2000
2/10/2011-----500
8/5/2011------1000
With YTD the value is: 1500
What I need is: 3500
I really appreciate any help on this.
Something like:
SUM([Date].[Day].AllMembers, [Measures].[Value])
OR
SUM(OpeningPeriod([Date].[Day]):ClosingPeriod([Date].[Day]), [Measures].[Value]),
where [Date].[Day] - it's a level DAY of your dimension;
[Measures].[Value] - your measure.