LogoLogo
3.5.7
3.5.7
  • Introduction
  • Getting started
    • Installation
      • On-premises
        • Single-node
        • Multi-node
      • Azure Market Place
      • AWS Market Place
    • Tutorials
      • Amazon AWS CUR
      • Amazon AWS CUR (Athena)
      • Azure Stack
      • Azure EA
      • Azure CSP
      • Google Cloud
      • VMware vCloud
      • VMware vCenter
    • Concepts
      • User interface
      • Services
    • Releases
      • Upgrading to version 3
      • Known issues
      • Announcements
      • Archive
  • Reports
    • Accounts
    • Services
    • Instances
    • Summary
    • Budget
  • Services
    • Manage
    • Rates
    • Adjustments
    • Subscriptions
  • ACCOUNTS
    • Budget management
  • Data pipelines
    • Extract
      • Configuration
      • Templates
      • Script basics
      • Parslets
      • Subroutines
        • check_dateformat
        • check_dateargument
        • format_date
        • validate_response
      • Language
        • aws_sign_string
        • basename
        • buffer
        • csv
        • clear
        • discard
        • encode
        • encrypt
        • environment
        • escape
        • exit_loop
        • foreach
        • generate_jwt
        • get_last_day_of
        • gosub
        • gunzip
        • hash
        • http
        • if
        • json
        • loglevel
        • loop
        • match
        • pause
        • print
        • return
        • save
        • set
        • subroutine
        • terminate
        • unzip
        • uri
        • var
    • Transform
      • Transform Preview
      • Configuration
      • Language
        • aggregate
        • append
        • calculate
        • capitalise
        • convert
        • copy
        • correlate
        • create
        • default
        • delete
        • environment
        • event_to_usage
        • export
        • finish
        • if
        • import
        • include
        • lowercase
        • normalise
        • option
        • rename
        • replace
        • round
        • services
        • set
        • split
        • terminate
        • timecolumns
        • timerender
        • timestamp
        • update_service
        • uppercase
        • var
        • where
    • Datasets
    • Lookups
    • Metadata
    • Reports
    • Workflows
  • Administration
    • User management
      • SAML2/LDAP
      • Users
      • Groups
    • Notifications
    • Settings
      • Global Variables
  • Advanced
    • Integrate
      • GUI automation
        • Examples
      • API docs
      • Single sign-on
        • Azure-AD
        • Auth0
        • OneLogin
        • ADFS
        • LDAP
    • Security
    • Digging deeper
      • Authentication flows
      • Transformer datadate
      • Dataset lifecycle
      • Config.json
      • Directories
      • Databases
  • Terms & Conditions
  • Privacy Policy
Powered by GitBook
On this page
  • Syntax
  • Code Snippet

Was this helpful?

Export as PDF
  1. Data pipelines
  2. Extract
  3. Subroutines

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

gosub check_dateargument ()

Code Snippet

subroutine check_dateargument {
	# Validate that amount of input arguments is as expected
	if (${ARGC} != 2) {
		if (${ARGC} == 1) {
			print "Running in 1 day mode"
			var firstday = ${ARG_1}
			var lastday = (@DATEADD(${firstday}, 1))
		} else {
			print "This requires 1 or 2 arguments, the day to collect usage for, and the date following that day, both in YYYYMMDD format"
			terminate with error
		}
	} else {
		var firstday = ${ARG_1}
		var lastday = ${ARG_2}
	}
	
	# Validate that to date is not before from date
	if (${firstday} > ${lastday}) {
		print "TO date cannot be a date that lies before FROM date"
		terminate with error
	}
	# Validate that to date is not the same as from date
	if (${firstday} == ${lastday}) {
		print "TO date cannot be the same as FROM date"
		terminate with error
	}
}
Previouscheck_dateformatNextformat_date

Last updated 4 years ago

Was this helpful?