Jump to content
Macro Express Forums

Extract Day from dynamic date....


Recommended Posts

Here's a good dilema for you Gurus: Using MEpro, I have a loop of the form of

\\simplified version!===========================

Set varCounter =0

Set varDynamicDate = today

LOOP UNTIL varCounter = 35

-Extract day of week (ddd) from varDynamicDate put it in varWeekday

--Logic: IF varWeekday = "Sat"

--OR

--IF varWeekday = "Sun"

---go to label: WeekendSkip

--ELSE it's not a weekend so varCounter = varCounter +1

--END IF

-Label: WeekendSkip

-on each loop ADD varDynamicDate = varDynamicDate +1

END LOOP

Text Box display: "35 days later is %varDynamicDate%

\\===================================

 

Basically this is a loop that will count 35 days into the future, EXCLUDING weekends.

 

The problem is that I can't see how to extract "ddd" from anything but "today." Does anyone else see a way?

 

Thanks for any ideas ;) -steve

=====

I'll post my actual code incase anyone wants to tinker with it... I think it might have an additional bug that causes it to loop endlessly ... haven't gotten to the point of debugging that part though :rolleyes:

 

Note that it's more coplicated than the above.. Lets you choose the start date and also excludes a list of public school holidays....

 

<COMMENT Value="Determine today and change it to a decimal."/>
<DATE/TIME Flags="\xB0" Date="12/19/2008 8:45:26 PM" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%vDatDateNow%" IsDateVar="TRUE"/>
<CONVERT DATE/TIME TO DECIMAL Source="%vDatDateNow%" Dest="%vDecDateNow%"/>
<COMMENT Value="Either choose 'today' or select your own date >> gets turned into \"vDecStart.\""/>
<MULTIPLE CHOICE MENU Style="\x00" Result="\x01" Dest="%vTxtStartFrom%" Title="Start counting from..." Prompt="Whould you like to count from today (%vDatDateNow%) or choose a custom date?" Options="Today\r\nChoose" Left="Center" Top="Center" Monitor="0" Width="443" Height="296" OnTop="FALSE"/>
<IF VARIABLE Variable="%vTxtStartFrom%" Condition="\x00" Value="Today" IgnoreCase="FALSE"/>
<VARIABLE SET DECIMAL Option="\x00" Destination="%vDecStart%" Value="%vDecDateNow%"/>
<END IF/>
<IF VARIABLE Variable="%vTxtStartFrom%" Condition="\x00" Value="Choose" IgnoreCase="FALSE"/>
<DATE/TIME Flags="\xB3" Date="12/22/2008 10:01:29 AM" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Prompt="Choose the STARTING date." Left="Center" Top="Center" Monitor="0" Variable="%vDatStartChoice%" IsDateVar="TRUE"/>
<CONVERT DATE/TIME TO DECIMAL Source="%vDatStartChoice%" Dest="%vDecStart%"/>
<END IF/>
<COMMENT Value="Change it to an Integer to round it, then change it back to a Decimal."/>
<VARIABLE MODIFY INTEGER Option="\x00" Destination="%vIntStart%" Value1="%vDecStart%" Value2="0"/>
<VARIABLE MODIFY DECIMAL Option="\x00" Destination="%vDecStart%" Value1="%vIntStart%" Value2="0"/>
<TEXT BOX DISPLAY Title="starting at " Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Starting at %vDecStart%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
<COMMENT Value="Choose how many days to count.  (only 35 works)"/>
<MULTIPLE CHOICE MENU Style="\x00" Result="\x01" Dest="%vTxtTimeline%" Title="What kind of timeline?" Prompt="Choose the type of timeline you would like to calculate ..." Options="35 School Days\r\n45 Calendar Days\r\n25 School Days\r\n60 Calendar Days\r\n30 School Days" Left="Center" Top="Center" Monitor="0" Width="443" Height="296" OnTop="FALSE"/>
<IF VARIABLE Variable="%vTxtTimeline%" Condition="\x00" Value="35 School Days" IgnoreCase="FALSE"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%vIntLengthofTimeline%" Value="35"/>
<VARIABLE SET BOOL Destination="%vBooIsSchDay%" Command="263" Value="TRUE" _ENABLED="FALSE"/>
<ELSE/>
<TEXT BOX DISPLAY Title="Not yet implemented " Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Not yet implemented.\r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<END IF/>
<COMMENT Value="Get together the needed variables.  "/>
<VARIABLE SET STRING Option="\x00" Destination="%vTxtHolidates%" Value="9/12/2008,  10/11/2008,  10/30/2008,  10/31/2008,  11/27/2008,  11/28/2008,  12/5/2008,  12/22/2008,  12/23/2008,  12/24/2008,  12/25/2008,  12/26/2008,  12/27/2008,  12/28/2008,  12/29/2008,  12/30/2008,  12/31/2008,  1/1/2009,  1/2/2009,  1/19/2009,  1/20/2009,  2/16/2009,  2/17/2009,  3/25/2009,  3/26/2009,  3/27/2009,  3/30/2009,  3/31/2009,  4/1/2009,  4/2/2009,  4/3/2009,  5/22/2009,  5/25/2009,  6/16/2009,  6/17/2009,  6/18/2009,  6/19/2009,  6/20/2009,  6/21/2009,  6/22/2009,  6/23/2009,  6/24/2009,  6/25/2009,  6/26/2009,  6/27/2009,  6/28/2009,  6/29/2009,  6/30/2009,  7/1/2009,  7/2/2009,  7/3/2009,  7/4/2009,  7/5/2009,  7/6/2009,  7/7/2009,  7/8/2009,  7/9/2009,  7/10/2009,  7/11/2009,  7/12/2009,  7/13/2009,  7/14/2009,  7/15/2009,  7/16/2009,  7/17/2009,  7/18/2009,  7/19/2009,  7/20/2009,  7/21/2009,  7/22/2009,  7/23/2009,  7/24/2009,  7/25/2009,  7/26/2009,  7/27/2009,  7/28/2009,  7/29/2009,  7/30/2009,  7/31/2009,  8/1/2009,  8/2/2009,  8/3/2009,  8/4/2009,  8/5/2009,  8/6/2009,  8/7/2009,  8/8/2009,  8/9/2009,  8/10/2009,  8/11/2009,  8/12/2009,  8/13/2009,  8/14/2009,  8/15/2009,  8/16/2009,  8/17/2009,  8/18/2009,  8/19/2009,  8/20/2009,  8/21/2009,  8/22/2009,  8/23/2009,  8/24/2009,  8/25/2009,  8/26/2009,  8/27/2009,  8/28/2009,  8/29/2009,  8/30/2009,  8/31/2009,  9/1/2009,  9/2/2009,  9/3/2009, "/>
<CONVERT DECIMAL TO DATE/TIME Source="%vDecStart%" Dest="%vDatDateDynamic%"/>
<VARIABLE SET DECIMAL Option="\x00" Destination="%vDecDateDynamic%" Value="%vDecStart%"/>
<VARIABLE SET INTEGER Option="\x00" Destination="%vIntCountedDays%" Value="0"/>
<COMMENT Value="Start the loop. +++++++++++++++++++++++++++"/>
<REPEAT UNTIL Variable="%vIntCountedDays%" Condition="\x00" Value="%vIntLengthofTimeline%"/>
<VARIABLE SET STRING Option="\x00" Destination="vTxtDateDynamic" Value="%vDatDateDynamic%"/>
<DATE/TIME Format="ddd" Flags="\xB0" Date="12/23/2008 10:01:41 AM" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%vTxtWeekday%" IsDateVar="FALSE"/>
<IF VARIABLE Variable="%vTxtWeekday%" Condition="\x00" Value="Sat" IgnoreCase="FALSE"/>
<OR/>
<IF VARIABLE Variable="%vTxtWeekday%" Condition="\x00" Value="Sun" IgnoreCase="FALSE"/>
<OR/>
<COMMENT Value="Check to see if vTxtDateDynamic's current date is a holiday."/>
<IF VARIABLE Variable="%vTxtHolidates%" Condition="\x06" Value="%vTxtDateDynamic%" IgnoreCase="FALSE"/>
<GOTO Name="NotSchoolDay"/>
<END IF/>
<COMMENT Value="If it's NOT a weekend or holiday then  increment the counter."/>
<VARIABLE MODIFY INTEGER Option="\x00" Destination="%vIntCountedDays%" Value1="%vIntCountedDays%" Value2="1"/>
<TEXT BOX DISPLAY Title="Counted days is " Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Counted days is %vIntCountedDays%\r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
<LABEL Name="NotSchoolDay"/>
<VARIABLE MODIFY DECIMAL Option="\x00" Destination="%vDecDateDynamic%" Value1="%vDecDateDynamic%" Value2="1"/>
<END REPEAT/>
<COMMENT Value="Loop ends. +++++++++++++++++++++++++++++"/>
<TEXT BOX DISPLAY Title="The due date is ...." Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Due date is %vDatDateDynamic%...\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

Link to comment
Share on other sites

I don't have Pro at work, but I can make this work in ME 3. If this code works in ME 3, it should also work in Pro.

 

Ultimately, it may not do exactly what you want for the rest of your macro, but it definitely extracts the ddd I'm looking for.

 

Basically, since every week is made up of two week-end days, you tell the macro how many week-days into the future you want to count,

then the macro calculates the number of week-end days (simple math) and adds that number to the week-days you want. Then it tells you

what day of the week that day will be.

 

Here you go:

Variable Set Decimal %D1% from Prompt
Variable Modify Decimal: %D2% = %D1% / 5
Variable Modify Decimal: %D3% = %D2% * 2
Variable Modify Decimal: %D4% = %D3% + %D1%
Variable Modify Decimal: Convert %D4% to text string %T3%
Variable Modify String: Convert %T3% to integer %N1%
Date/Time: Save "ddd" into %T2%
Text Box Display: T2

<DVAR2:01:02:FFFCenter:Center><DMVAR:04:02:1:000000000000001.0000:2:5><DMVAR:03:03:1:000000000000002.0000:2:2><DMVAR:01:04:1:000000000000003.0000:1:000000000000001.0000><DMVAR:05:04:1:000000000000003.0000:1:000000000000010.0000><TMVAR2:05:03:01:000:000:><DT:dddT:02:3:{F0%N1%}{P00000}{P00000}{P00000}><TBOX4:T:1:CenterCenter000278000200:000:T2%T2%>

 

My tests originally included 35 days, 34 days, and 36 days with the (accurate) results: Tue, Mon, and Wed respectively. I just got the thought

to check 33 days, which came out Sun, so this macro is still flawed. But at the very least it was fun to try. I don't have time to mess with it

more right now, so hopefully somebody else will be able to give you a more informed answer.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...