Return Day (Monday) from Date (11/19/2007)
Today, we'll format a date (11/19/2007) into readable week day format (Monday) using Meditech's Magic programming language for the Client Server (CS) & Magic platforms.
Put this into a start macro:
"MONDAY"^/DAY^/DAY[/DAY:3T],
"TUESDAY"^/DAY^/DAY[/DAY:3T],
"WEDNESDAY"^/DAY^/DAY[/DAY:3T],
"THURSDAY"^/DAY^/DAY[/DAY:3T],
"FRIDAY"^/DAY^/DAY[/DAY:3T],
"SATURDAY"^/DAY^/DAY[/DAY:3T],
"SUNDAY"^/DAY^/DAY[/DAY:3T]
Call the start macro from the footnote: AL START start
When you run the report, this is what your array looks like in memory:
/DAY["MON"] = "MONDAY"
/DAY["TUE"] = "TUESDAY"
/DAY["WED"] = "WEDNESDAY"
/DAY["THU"] = "THURSDAY"
/DAY["FRI"] = "FRIDAY"
/DAY["SAT"] = "SATURDAY"
/DAY["SUN"] = "SUNDAY"
Put this in your xx.field which will be on the report picture to return a day from a date:
DAT=FREE
JFY=L
LEN=10
VAL=/DAY[%Z.day.out(%Z.day.from.date(@date))]
Walking thru the code:
- @date is returned from the SCH module I'm working in today as: 10/22/07.
- %Z.day.from.date(@date) OR %Z.day.from.date("10/22/07") returns: 2.
- %Z.day.out(%Z.day.from.date(@date)) OR %Z.day.from.date("2") returns: MON.
- /DAY[%Z.day.out(%Z.day.from.date(@date))] OR /DAY["MON"] returns: MONDAY.
You can change the format to match your business needs. Some reports look better with the day formatted as Monday. In that case, your start macro /DAY array would look more like this:
"MON"^/DAY.SUB,"Monday"^/DAY[/DAY.SUB],
"TUE"^/DAY.SUB,"Tuesday"^/DAY[/DAY.SUB],
"WED"^/DAY.SUB,"Wednesday"^/DAY[/DAY.SUB],
"THU"^/DAY.SUB,"Thursday"^/DAY[/DAY.SUB],
"FRI"^/DAY.SUB,"Friday"^/DAY[/DAY.SUB],
"SAT"^/DAY.SUB,"Saturday"^/DAY[/DAY.SUB],
"SUN"^/DAY.SUB,"Sunday"^/DAY[/DAY.SUB]
Your structure now looks like this:
/DAY["MON"] = "Monday"
/DAY["TUE"] = "Tuesday"
/DAY["WED"] = "Wednesday"
/DAY["THU"] = "Thursday"
/DAY["FRI"] = "Friday"
/DAY["SAT"] = "Saturday"
/DAY["SUN"] = "Sunday"
In review, we've formatted a date "11/19/2007" to print as a day in 2 formats "MONDAY" & "Monday". And we've done it only coding our xx.field once!
Happy Monday & Happy Thanksgiving!

3 Comments:
Why not just use this:
VAL=%Z.day.out(%Z.day.from.date(@date))_"DAY"
or
VAL=%Z.day.out(%Z.day.from.date(@date))_"day" if B is true (mixed case).
I don't think you need /DAY.
scratch that... it won't work, ie THUDAY
OK, here you go...
",Sun,Mon,Tues,Wednes,Thurs,Fri,Satur"#(%Z.day.from.date(@date)_",")_"day"
Post a Comment
Links to this post:
Create a Link
<< Home