353
Views
17
Comments
Subtract days to the current date
Question
Application Type
Reactive
Service Studio Version
11.54.35 (Build 62969)
Platform Version
11.25.0 (Build 41684)

I have a date filter where there is from and to date my TO date is the current date, but i want my FROM date to be 1 week before the current date is there a way to execute this? i tried the adddays(currdate(), -7)

2024-05-08 06-29-37
Prince Aadil Khan Panwar

Hi Jesus Carlos,

Oninitialize action of screen

Set the date variable

As datetimetodate(currdate(),-7)

Hope this helps 

Prince

UserImage.jpg
budang haba

Thanks for replying and im new to outsystem can you tell me where is the on initialize ? thank you

2024-05-08 06-29-37
Prince Aadil Khan Panwar

Select the screen and check into the properties section and select the actions for the events oninitialize action.

UserImage.jpg
budang haba

thank you for pointing it out but the error says "Too many arguments specified for function 'CurrDate'. "

2024-05-08 06-29-37
Prince Aadil Khan Panwar

sorry my bad. i forgot to write this exactly what it should be

DateTimeToDate(AddDays(CurrDate(),-7))


2024-12-18 16-06-42
Junaid Syed

Hello Jesus,

Usually filters are on the screen to allow users to change the values. However, in your case it seems you are fixing the date range to past one week, they you probably don't even need the date filters on the screen. You could simply provide a selection "Last Week", when user selects it you perform the date range calculation in your logic and fetch the data accordingly.

Hope it helps!

Junaid

2023-04-17 05-19-55
Vaishali Shrivastava

Hi Jesus,


You can use date picker and set the initial date as AddDays(CurrDate(), -7)


Hope this will help you.

UserImage.jpg
budang haba

Thanks for the help but this time i dont use date picker only input date time type

2023-11-22 10-51-50
Jozy Sohail

Hi Jesus,

If your To and From date values are fixed, i.e. currentDate and 7 days before current date, then you should follow the approach that Junaid suggested. 

Just assign the values in your logic for ToDate=Currdate() and FromDate=adddays(currdate(), -7) .

Hope it helps.

Thanks

UserImage.jpg
budang haba

to date currdate works but the  FromDate=adddays(currdate(), -7) .  doesnt work. thanks

2023-11-22 10-51-50
Jozy Sohail

Hi Jesus,

Can you please help me to understand the error or problem you are facing while using adddays function? 

Thanks

UserImage.jpg
budang haba

it doesnt add anything or subtract anything just the month and time format displayed 

2023-11-22 10-51-50
Jozy Sohail

can you please show me how are you using it with the help of a screen shot?

it works like this.

2025-03-26 05-54-25
Palaniraja Paraman

Hi Jesus, 

FormatDateTime(AddDays(CurrDate(),-7),"dd/MM/yyyy") => Use this expression in the To field.

Make Sure, Don't use input box use expression. Thanks

UserImage.jpg
budang haba

im putting this code to the prompt and it does not work. thanks

UserImage.jpg
Mahammadirfan Machapur

Hi Jesus, 

can you please share some screenshots.where exactly you are facing this problem.

2024-09-09 08-44-46
BHUPENDRA SINGH

Hi Jesus,

Use the screen "OnReady" event and assign "FromDate" as below using "Todate" having Defaultvalue as CurrDate().

Also similar logic/assignment can be used in "OnChange" event of "ToDate" input widget to get new "FromDate" value  as per value selected in "ToDate" input.

Please check below demo:

https://personal-49wyaomr.outsystemscloud.com/ReactiveAppDemo_Th/DateDemo

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.