If you’re a software developer using popular languages such as C# and Java, you’re used to a lot of string formatting options for dates.
For example, in C#, this line of code will look familiar.
DateTime thisDate = new DateTime(2014,1,1);
string date_str=thisDate.ToString(“MMMM dd, yyyy”);
The variable date_str will look like this: January 1, 2014
Unfortunately, I wasn’t able to find something similar in WebFOCUS. There a lot of date functions to choose from, but that’s a double edge sword; you can do a lot of with dates which gives you flexibility, but it can be confusing when to use what functions and makes it difficult to remember.
I created a custom function that simplifies this task of turning dates into strings (ALPHAs). You can download this WebFOCUS date utility.
Here’s an example of how you can use it:
TABLE FILE CAR
COMPUTE DATETIME/HYYMDs =‘2014-01-02 23:58:59’;
COMPUTE Text2/A100 = DATETIME.TOSTRING(DATETIME,‘MMM YY’);
COMPUTE DATE/YYMD = ‘2013-01-03’;
COMPUTE Test/A100 = DATE.TOSTRING(DATE,‘MMM ”YY’);
Here are all the available formats you can use in my custom function – everything is case sensitive!
Of course, much more can be done, but this covers the majority of the use cases that I typically run into.
Feel free to extend as you need. If you need help, extending the functionality, shoot me an email at: email@example.com