Bluepoint Design

Practical Cost-Effective Solutions
Macro Express Sample Macro: Day of Year

Home
Up
Date Time Parsers
Building TSV Files
eMail Validation
Multiple Choice Trick
Occurrences
Repeat Validation
GoTo
First file
Fax PDF Breakup
Day of Year
Multiple Attachments
Multiple eMail Addresses
Text Padding
Update: This macro was essentially replaced with the Text to Serial Time macro.

This very simple macro results in the integer day of the year and also also accounts for leap year. It is written to take today's date but can easily be modified to work with any date.

Warning: Does not work with years divisible by 100.

Hint: If you would like the Excel date value, that is the integer that that Excel and many other applications actually saves dates in, you can simply add 39,082 to the day number. This will only work for 2007

Page last updated: 06/24/2009

Day_of_Year.mex
Macro Script
<DT:M T:01:1:><DT:D T:02:1:><DT:Y T:03:1:><TMVAR2:05:01:01:000:000:><TMVAR2:05:02:02:000:000:><TMVAR2:05:03:03:000:000:><IFVAR2:2:01:4:1 ><IVAR2:05:01:31><ENDIF><IFVAR2:2:01:4:2 ><NMVAR:04:04:1:0000003:2:0000004><NMVAR:03:04:1:0000004:2:0000004><IFVAR2:5:03:1:N4 ><NMVAR:01:05:1:0000005:2:0000029><ELSE><NMVAR:01:05:1:0000005:2:0000028><ENDIF><ENDIF><IFVAR2:2:01:4:3 ><NMVAR:01:05:1:0000005:2:0000031><ENDIF><IFVAR2:2:01:4:4 ><NMVAR:01:05:1:0000005:2:0000030><ENDIF><IFVAR2:2:01:4:5 ><NMVAR:01:05:1:0000005:2:0000031><ENDIF><IFVAR2:2:01:4:6 ><NMVAR:01:05:1:0000005:2:0000030><ENDIF><IFVAR2:2:01:4:7 ><NMVAR:01:05:1:0000005:2:0000031><ENDIF><IFVAR2:2:01:4:8 ><NMVAR:01:05:1:0000005:2:0000031><ENDIF><IFVAR2:2:01:4:9 ><NMVAR:01:05:1:0000005:2:0000030><ENDIF><IFVAR2:2:01:4:10 ><NMVAR:01:05:1:0000005:2:0000031><ENDIF><IFVAR2:2:01:4:11 ><NMVAR:01:05:1:0000005:2:0000030><ENDIF><NMVAR:01:05:1:0000005:1:0000002><TBOX4:T:1:CenterCenter000278000200:000:Results %N5% >
Macro Text
Date/Time: Save "M" into %T1%
Date/Time: Save "D" into %T2%
Date/Time: Save "Y" into %T3%
Variable Modify String: Convert %T1% to integer %N1%
Variable Modify String: Convert %T2% to integer %N2%
Variable Modify String: Convert %T3% to integer %N3%
If Variable %N1% > 1
Variable Set Integer %N5% to 31
End If
If Variable %N1% > 2
Variable Modify Integer: %N4% = %N3% / 4
Variable Modify Integer: %N4% = %N4% * 4
If Variable %N3% = variable %N4%
Variable Modify Integer: %N5% = %N5% + 29
Else
Variable Modify Integer: %N5% = %N5% + 28
End If
End If
If Variable %N1% > 3
Variable Modify Integer: %N5% = %N5% + 31
End If
If Variable %N1% > 4
Variable Modify Integer: %N5% = %N5% + 30
End If
If Variable %N1% > 5
Variable Modify Integer: %N5% = %N5% + 31
End If
If Variable %N1% > 6
Variable Modify Integer: %N5% = %N5% + 30
End If
If Variable %N1% > 7
Variable Modify Integer: %N5% = %N5% + 31
End If
If Variable %N1% > 8
Variable Modify Integer: %N5% = %N5% + 31
End If
If Variable %N1% > 9
Variable Modify Integer: %N5% = %N5% + 30
End If
If Variable %N1% > 10
Variable Modify Integer: %N5% = %N5% + 31
End If
If Variable %N1% > 11
Variable Modify Integer: %N5% = %N5% + 30
End If
Variable Modify Integer: %N5% = %N5% + %N2%
Text Box Display: Results
Variables:
N1 Month
N2 Day
N3 Year
N4 Leap year determination
N5 Number of days so far this year.

T1 Month
T2 Day
T3 Year
 
Practical Cost-Effective Solutions