I would like to run a query likeselect ... as days where `date` is between '2020-04-07' and '2020-04-12'And return data like:days----------2020-04-072020-04-082020-04-092020-04-102020-04-112020-04-12How can i do that in OS?
Hi Gen Rag, you can use a SQL (normal query with input parameter with the dates you need) or an aggregate with the filters and input parameter with the dates you need
But if the question is how to do it, you can follow this link and you will find a few examples of the SQL BETWEEN Operator or this one about SQL Queries in OutSystems
Hi, friend.
You need to do that through UI or just in aggregate?
In the aggregate filter, type:
Entity.Attribute >= TextToDate("2020-04-07") and
Entity.Attribute <= TextToDate("2020-04-12")
Best regards
Here is an example of SQL query using 2 dates from the Booking application from the Web Developer Bootcamp
and here is an example with agregates
here a test selecting 2 dates
Hope I could help you
sorry if my question is unclear,I want to generate record automatic based on date between two date range. i have two table1. Table Period (to declare date range)Id |StartDate | EndDate 1 |2020-04-07 | 2020-04-122. Table Result (automatic generate record from date between '2020-04-07' and '2020-04-12', this table default null record)PeriodId |Date |Description1 |2020-04-07 |Tuesday1 |2020-04-08 |Wednesday1 |2020-04-09 |Thursday1 |2020-04-10 |Friday1 |2020-04-11 |Saturday1 |2020-04-12 |Sunday
How can i do that in OS?
i try to use this query:select * from (select adddate('1970-01-01',t4*10000 + t3*1000 + t2*100 + t1*10 + t0) gen_date from (select 0 t0 union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0, (select 0 t1 union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1, (select 0 t2 union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2, (select 0 t3 union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3, (select 0 t4 union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) vwhere gen_date between '2020-04-07' and '2016-04-12';but error in OS (in MySQL, query no error).
Gen Rag wrote:
But you need to be an SQL? do you want to generate in the screen and present the result? Do you want to save? Cuz if you don't need a SQL you can use the solution proposed by Nikhil Gaur and generate the result you want.
Give more context if possible, take photos, upload the oml, etc
Carlos Lessa wrote:
Hi Carlos Lessa,
I just need solution to generate automatic record between two date, and i think, i can use SQL to solve that. but it doesn't seem like the right way.I try to use solution from Nikhil Gaur.
Thank for your help :)
Hi Gen,
You just want all the date between two dates and you are not getting data from any database table/ entity then may I know why you want to get them from database using SQL query?
You can do this using a simple loop in your server or client action.
Nikhil Gaur wrote:
Hi Nikhil Gaur,
Yes, i just want all the date between two dates and generate automatic record in table from that.before, i want to get between two date from sql and parsing value date from SQL result to create record in table.but I think, i can use solution from you. it more simple. Thanks for your help :)
hi Nikhil Gaur,
how can i write above solution loop date range to save button in react web app outsystems.And then I tried it GetDates server action for example (input StartDdate is date type,input EndDate is date type)and DateList is date list type is it correct.
but , I have one error when i assign StartDate .
can you help me clear answer this question.
if you answer this question please step by step png because I don't have oml.
You want to do this from SQL then below query will help you -
DECLARE @MinDate DATE = '20200412', @MaxDate DATE = '20200424';SELECT fn.cur_date,DATENAME(dw,fn.cur_date) as day_name,DATENAME(month,fn.cur_date) as month_name FROM (SELECT TOP (DATEDIFF(DAY, @MinDate, @MaxDate) + 1) cur_date = DATEADD(DAY, ROW_NUMBER() OVER(ORDER BY a.object_id) - 1, @MinDate)FROM sys.all_objects a CROSS JOIN sys.all_objects b ) fn
Regards,
Rajat Agrawal
Rajat Agrawal wrote:
Hi Rajat Agrawal,i try your query, and it's work :D
i will try your solution and Nikhil Gaur.Thank for your help :)
Good to see that we were able to help you to solve your problem.
Please mark the answer as solution which you think was most suitable for your problem.
Hello, I know that this issue has been already solved. I've already try simple method from Nikhil Gaur and it's work fine but I have another problem. I just want to put my query from SQL into the table to look like this
from the picture if there is a record in my query from SQL it will show at the same day as it's create but if it doesn't it will show "-" instead
Right now I got the table that look like this
and this is the property of my table
this is GetDates Action
this is what inside my preparation
and this is record from SQL that I want to show in the table
I have already try many methods but It doesn't work for me so can anyone help me to fix this issue?
or maybe just make an example so I can get the idea.
If you have your answer, could you please mark the post with that answer as a solution. This way the question is marked solved and others can benefit from it.
Thank you.