Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only. Moving forward, myibi is our community platform to learn, share, and collaborate. We have the same Focal Point forum categories in myibi, so you can continue to have all new conversations there. If you have any questions or need access: Contact myibi@ibi.com


Connect to myibi
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Adding Number of Days to Dates

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Adding Number of Days to Dates
 Login/Join
 
Platinum Member
posted
I have 2 A15 dates:

05/16/2005 ->Date 1

and

06/3/2005 ->Date 2

How can I add 25 days to Date 1 giving me a Date 3?

Then using Date 3 determine if Date 2 is less than Date 3.

I've looked up some info on subtracting dates, but nothing has jumped out at and, and since these are alpha I wasn't sure they would work the same way.

Can anyone help?

Thanks so much!
 
Posts: 178 | Registered: May 11, 2005Report This Post
Expert
posted Hide Post
sure
look up the AYMD function.
you'll need to translate these character strings into smart dates, there are many ways to do that. one way uses the date convert function DATECVT. Smart dates being the focus word for integers underlying the date formatting map, integers representing the number of days elapsed since the base date of jan1 1900. Smart dates are the way to do all the arithmetic you need.
Look them both up in your FUNCTIONS manual
There are a number of threads on this board about DATES. So do a board search here as well.
You'll enjoy what you'll learn.
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Platinum Member
posted Hide Post
Right, I had used datecvt, but I keep recieving errors and I am not sure why.

ND/DMY = DATECVT(DATE, 'MDYY', 'DMY');
ND/DMY = DATECVT(DATE, 'a255', 'DMY');

I have tried both of those...DATE is the name of the field that holds the date I need that is A255 but I want it to be in date format so that I can perform arithmetic.

The error tells me: (FOC36355) INVALID TYPE OF ARGUMENT #1 FOR USER FUNCTION DATECVT

But I need the first argument cause that is the date... not sure what to do.
I appreciate the AYMD hint (never seen that one), I assume I will use that once I figure this first part out.
 
Posts: 178 | Registered: May 11, 2005Report This Post
Silver Member
posted Hide Post
The WebFOCUS 53 "Using Functions" Document (DN4500583.0904) has the following explanation for using the DATECVT function.

DATECVT(date, 'infmt', 'outfmt'[, outfield])


WHERE
infmt
Alphanumeric
Is the format of the date enclosed in single quotation marks. It is one of the following:
* A non-legacy date format (for example, YYMD, YQ, M, DMY, JUL).
* A legacy date format (for example, I6YMD or A8MDYY).
* A non-date format (such as I8 or A6). A non-date format in infmt functions as an offset from the base date of a YYMD field (12/31/1900).


Going by that you should be able to use the following code to convert the date

DEFINE FILE CAR
-* Using A8MDYY Format
DATEA8/A8 WITH CAR = '01012005';
DTEONE/MDYY = DATECVT(DATEA8,'A8MDYY','MDYY');
-* USING A6 Format Approximately 100 years (365 * 100) from the base date of (12/31/1900)
DATEA6/A6 = '36500';
DTETWO/MDYY = DATECVT(DATEA6,'A6','MDYY');
END
TABLE FILE CAR
PRINT
DATEA8
DTEONE
DATEA6
DTETWO
END
Hope that helps
M

This message has been edited. Last edited by: <Maryellen>,
 
Posts: 33 | Location: New York, USA | Registered: August 11, 2003Report This Post
Platinum Member
posted Hide Post
Thanks for all the help. For some reason perhaps because I was pulling the date from an Oracle DB and it was an A255 I kept getting the same problem.

What I ended up doing was converting it in the SQL passthru that I used and then used HDATE to format it the way I needed.

Thanks!
 
Posts: 178 | Registered: May 11, 2005Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Adding Number of Days to Dates

Copyright © 1996-2020 Information Builders