Search…
check_dateargument
including 1 day mode
This Subroutines checks if the FROM and TO date are in order. In the case that there is only 1 day entered, it will automatically fill in the second day in a "1 Day Mode".

Syntax

1
gosub check_dateargument ()
Copied!

Code Snippet

1
subroutine check_dateargument {
2
# Validate that amount of input arguments is as expected
3
if (${ARGC} != 2) {
4
if (${ARGC} == 1) {
5
print "Running in 1 day mode"
6
var firstday = ${ARG_1}
7
var lastday = (@DATEADD(${firstday}, 1))
8
} else {
9
print "This requires 1 or 2 arguments, the day to collect usage for, and the date following that day, both in YYYYMMDD format"
10
terminate with error
11
}
12
} else {
13
var firstday = ${ARG_1}
14
var lastday = ${ARG_2}
15
}
16
17
# Validate that to date is not before from date
18
if (${firstday} > ${lastday}) {
19
print "TO date cannot be a date that lies before FROM date"
20
terminate with error
21
}
22
# Validate that to date is not the same as from date
23
if (${firstday} == ${lastday}) {
24
print "TO date cannot be the same as FROM date"
25
terminate with error
26
}
27
}
Copied!
Last modified 5mo ago
Export as PDF
Copy link