is there any default function to get no. of days of the current year or any year? please suggest.
That's quite easy:
DiffDays(NewDate(TargetYear, 1, 1), NewDate(TargetYear + 1, 1, 1))
DiffDays is a built-in function that returns the difference in days between two dates, NewDate is a built-in function that creates a date from year, month and day components. The difference in days of two consecutive 1 January dates is the number of days in the first year.
Hi @Priya Naveen
You can get number of days between any specific period by using DiffDays(,) function available in OutSystems. It can be used in any expression.
For Example, For getting no. of days till today in current year, you can use days = DiffDays(#2024-01-01#,CurrDate())+1 // days = 134
i want a functionlaity if give year as input it should give us number days for that year. suggest
Hello @Priya Naveen
You can simply check for a leap year, if the input year is a leap year then you can show 366 days else the year have 365 days.
To create a function create a client action and write your logic there and give an output that will return the days.
Here is how you can ,take any client action as a function -
You can also do the same to sever action if you have server side requirement.
attaching one example
ThanksTousif Khan
This is an overcomplicated answer, as you don't need to check for a leap year. Just use DiffDays.
You can try that formula in expression to get the no of days in any year.
If((Mod(Year,4) = 0 and Mod(Year,100) >0 ) or (Mod(Year,400) = 0),366,365)
Hi @Priya Naveen 1) There is no direct default function in outsystems to get the number of days in the year, but indirectly, you can achieve that with the existing function, if you are specifying a year alone, you can use Mod() function.
2) You can calculate the number of days between currdate() and required date() with the Diffdays() function. As @ RAHUL KUMAR mentioned, use DiffDays(#2024-01-01#,CurrDate())+1 and add both outputs to get a total number of days.
3) For better results, you can try different combinations of existing functions under date &time based on your requirements.
Check this Oml
Again, an overcomplicated answer. You do not use such complicated trickery. See my previous comment for the simplest solution.
thank u