Deliver Awesome UI with the most complete toolboxes for .NET, Web and Mobile development
Automate UI, load and performance testing for web, desktop and mobile
A complete cloud platform for an app or your entire digital business
Detect and predict anomalies by automating machine learning to achieve higher asset uptime and maximized yield
Automate decision processes with a no-code business rules engine
Optimize data integration with high-performance connectivity
Connect to any cloud or on-premises data source using a standard interface
Build engaging multi-channel web and digital experiences with intuitive web content management
Personalize and optimize the customer experience across digital touchpoints
Build, protect and deploy apps across any platform and mobile device
Rapidly develop, manage and deploy business apps, delivered as SaaS in the cloud
I need to add 2 days to a date. I know I have to adjust for a leap year and if the day happens to be greater than or equal to the 28th and for some months having 30 or 31 days. I am stuck at the beginning. I try to create the first condition to check for the actual day. If I assign before the if loop the first part works. But using the assign in the if/else loop fails. What am I doing wrong... if you have other ideas on the month or 30 vs 31 days I would appreciate that. Thanks.
DO: ASSIGN FRAME fmain txtName. DEF VARIABLE v_date_increment AS CHAR. /* ASSIGN v_date_increment = STRING(DAY(TODAY),"99"). */ IF DAY(TODAY) LE 28 THEN ASSIGN v_date_increment = STRING(DAY(TODAY) + 2,"99"). MESSAGE "Hello, " v_date_increment "!" VIEW-AS ALERT-BOX. ELSE ASSIGN v_date_increment = STRING(DAY(TODAY),"99"). MESSAGE "Hello, " txtName "!" VIEW-AS ALERT-BOX. txtName = "". DISPLAY txtName WITH FRAME fmain. APPLY "ENTRY" TO txtName. END.
I am doing that in STRING(DAY(TODAY) + 2... but there will be conditions where the day is not valid (ie. day is the 31st, it is february 27th...)
DEFINE VARIABLE MyDateVariable AS DATE NO-UNDO.
MyDateVariable = TODAY + 2.DISPLAY "Current Date: " TODAY "Two Days From Now: " MyDateVariable.
hermes, you are incorrect. Just increment the date variable itself, not the components (month, day, year). This is one of the things that the ABL makes very, very simple. You are thinking "old style" and making it much harder than it needs to be.
this post as spam/abuse.
You can use the add-interval function where you even can specify the "unit" ('days', 'months', 'weeks', ...):
MESSAGE add-interval(TODAY, 2, "days")
VIEW-AS ALERT-BOX INFO BUTTONS OK.
Yes on it's face that is correct but I was trying another way because there is formatting that needs to be done. The date should appear as 20150831 for today and not as 08/31/2015.
use the add-interval and do the formatting afterwards
vdtDate = add-interval(TODAY, 2, "days").
assign vcFormattedDate = string(year(vdtDate), "9999":u) + string(month(vdtDate), "99":u) + string(day(vdtDate), "99":u).
you can always re-format your date after the calculation:
define variable vdtDummy as date no-undo.
vdtDummy = add-interval(TODAY, 2, "days").
message string(year(vdtDummy), "9999") + string(month(vdtDummy), "99") + string(day(vdtDummy), "99")
view-as alert-box info.
All you have to is add the number of days as suggested... which always gives you a proper date regardless of leap year or switching months.
Then format the resulting variable by parsing the year,month and day...
DEFINE VARIABLE myDate AS DATE NO-UNDO.
ASSIGN myDate = TODAY + 2.
And instead of stringing date parts together, use the built-in iso-date function:
message replace( iso-date( today ), "-", "" ).
Great, Thanks peggycole that works great... Thanks everyone for your input.