MC Press Online Forum
Welcome, Guest
Please Login or Register.    Lost Password?
TechTip: Creating Functions to Get Day Names, Month Names, or Full Dates (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: TechTip: Creating Functions to Get Day Names, Month Names, or Full Dates
#121706
K.Forsythe (User)
Platinum Boarder
Posts: 349
graphgraph
User Offline Click here to see the profile of this user
TechTip: Creating Functions to Get Day Names, Month Names, or Full Dates 10 Months ago Karma: 0  
This thread discusses the Content article: TechTip: Creating Functions to Get Day Names, Month Names, or Full Dates

Depending on what release you're on this code may not work for you. I believe that the SQL functions used in this code were added in V5R3. So, if you're system is older than that, you need a different solution. Here is the code for the GetDayNam and GetMonNam functions, if you want to avoid using those SQL functions, either because you havn't upgraded to V5R3 yet, or if you just don't have the SQL precompiler on your system.

I tossed this example together in a hurry, but it seemed to work right when I tested it. If you spot any flaws, please share.

P GetDayNam B EXPORT
D PI 20
D InpDat D
D Start S D INZ(d'2008-02-04')
D Dif S 5I 0
D Day S 5I 0
D Nams S 20 Dim(7)

/Free
Nams(1) = 'Monday';
Nams(2) = 'Tuesday';
Nams(3) = 'Wednesday';
Nams(4) = 'Thursday';
Nams(5) = 'Friday';
Nams(6) = 'Saturday';
Nams(7) = 'Sunday';
dif = %diff(InpDat:Start:*D);
day = %rem(dif:7) + 1;
Return nams(Day);
/End-Free
P E

P GetMonNam B EXPORT
D PI 20
D InpDat D
D Nams S 20 Dim(12)
/Free
Nams(1) = 'January';
Nams(2) = 'February';
Nams(3) = 'March';
Nams(4) = 'April';
Nams(5) = 'May';
Nams(6) = 'June';
Nams(7) = 'July';
Nams(8) = 'August';
Nams(9) = 'September';
Nams(10) = 'October';
Nams(11) = 'November';
Nams(12) = 'December';
Return Nams(%SUBDT(InpDat:*M));
/End-Free
P E
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop
   MC-STORE.COM