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

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"/>

Related

Quicksight parse date into 3 days

I know Quicksight could help parse the time into DAY, WEEK, MONTH and YEAR in Field Wells, but how could I customize it into 3 days(72 hrs)? Is there any windowsFunction I could use?
You can introduce a calculated field with formula looking something like that:
addDateTime((extract("DD", {create_time})/3)*3, "DD", truncDate("DD", {create_time}))
And use it for grouping. Depends on your desired time interval it possibly will not do exactly what you need - cause it will group days in month by three, but you can use dateDiff and either some fixed date as starting point. For example:
addDateTime((dateDiff(parseDate("2020-01-01"), truncDate("DD", {create_time}))/3)*3, "DD", parseDate("2020-01-01"))

Calculate date difference and return number of days

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.

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.

SQL - filter values based on month & date

I'm currently strugeling to get something done.
I needed only the rows where the date is between a certain date and month.
Example show only the rows where the date is between 01/05 (DD/MM) and 08/07 (DD/MM) the date can be found in the table tasks within the field information.
The year can't make any sense, but the results may only between those two dates in that year.
I've tried:
BETWEEN (TO_DATE ('01/05','DD/MM') AND (TO_DATE('08/07', 'DD/MM')
EXTRACT (DD/MM) from information.
none of those are working for me, I hope that someone of you can help me to figure this out!.
Thanks!
You seem to want to disregard the year. If so, then I would recommend:
TO_CHAR(datecol, 'MM/DD') BETWEEN '05/01' AND '07/08'
In order for BETWEEN to work in this case, you need the format in the order of MM-DD.
If you want this for a particular year, then use direct date comparisons:
datecol >= DATE '2018-05-01' AND
datecol < DATE '2018-07-09' -- note this is one day later
Oracle dates have a time component, so you need to be careful when making comparisons.

Subtract Six Months From Date

I have a calendar and when I click on a date I have a popup that uses a query that uses a between criteria. This criteria I need to find the exact date 6 months prior to the one I clicked on which is [AbsenceDate]. Im not sure if the way below is the correct way to go because when I go on line HERE it gives me a few day different results than what access would so I don't know what would be correct. Is there a module I could use that would be better or is this good? Thanks...
Between DateAdd("d",-180,Date()) And [Forms]![frm_CalendarInputBox]![subFormCalendarInputBox].[Form]![AbsenceDate]
DateAdd can subtract months too, with Interval:="m":
Debug.Print DateAdd("m", -6, Date())
And in your query:
Between DateAdd("m",-6,[Forms]![frm_CalendarInputBox]![subFormCalendarInputBox].[Form]![AbsenceDate]) And Date()