LogoLogo
2.3.1
2.3.1
  • Introduction
  • Getting started
    • Installation
      • On-premises
      • Azure Market Place
      • AWS Market Place
    • Concepts
      • Datadate
      • Datasets
      • Program directory
      • Home directory
      • RDFs
      • Accounts
      • Services
    • Configuration
      • Data Sources
        • Extractors
        • Transformers
      • Catalogue
        • Adjustments
        • Rates
        • Services
      • Administration
        • Configuration
        • Users Groups
        • Workflows
    • Tutorials
      • Amazon AWS CUR
      • Azure EA
      • Azure CSP
      • Azure Stack
    • Releases
      • Upgrading to version 2
      • Archive
  • Diving deeper
    • Extract
      • Templates
      • Script basics
      • Parslets
      • Language
        • aws_sign_string
        • basename
        • buffer
        • csv
        • clear
        • discard
        • encode
        • encrypt
        • escape
        • exit_loop
        • foreach
        • get_last_day_of
        • gosub
        • gunzip
        • hash
        • http
        • if
        • json
        • loglevel
        • loop
        • match
        • pause
        • print
        • return
        • save
        • set
        • subroutine
        • terminate
        • unzip
        • uri
        • var
    • Transform
      • Language
        • aggregate
        • append
        • calculate
        • capitalise
        • convert
        • copy
        • correlate
        • create
        • default
        • delete
        • export
        • finish
        • if
        • import
        • include
        • lowercase
        • normalise
        • option
        • rename
        • replace
        • round
        • service
        • services
        • set
        • split
        • terminate
        • timecolumns
        • timerender
        • timestamp
        • update_service
        • uppercase
        • var
        • where
    • Report
      • Defining reports
      • Accounts
      • Services
      • Summary
    • Integrate
      • API docs
      • GUI automation
        • Examples
      • Single Sign On
        • Azure-AD
        • Auth0
Powered by GitBook
On this page
  • Syntax
  • Details
  • Example

Was this helpful?

Export as PDF
  1. Diving deeper
  2. Extract
  3. Language

get_last_day_of

The days_in_month statement sets a variable to contain the number of days in the specified month

Syntax

get_last_day_ofyyyyMMasvarName

Details

The get_last_day_of statement will set the value of the variable called varName to contain the number of days in the month specifed by yyyyMM where yyyy is a four-digit year and MM is a 2-digit month.

The statement will take leap years into account.

Example

#
# Check a specific date to see if it is the last day of a month
#
var somedate = 20180228
gosub detect_end_of_month(${somedate})

if (${is_last_day} == TRUE) {
    print ${somedate} is the last day of a month
} else {
    print ${somedate} is not the last day of a month
}

#
# Check todays date to see if it is the last day of the month
#
gosub detect_end_of_month()
if (${is_last_day} == TRUE) {
    print Today is the last day of the month
} else {
    print Today is not the last day of the month
}

# This subroutine determines whether a date is the last
# day of a month or not
#
# If no argument is provided it defaults to the current system
# time, else it uses the supplied yyyyMMdd format argument
#
# It sets a variable called 'is_last_day' to TRUE or FALSE

subroutine detect_end_of_month {

    if (${SUBARG.COUNT} == 0) {
        get_last_day_of ${YEAR}${MONTH} as last_day
		
        if (${last_day} == ${DAY}) {
            var is_last_day = TRUE
        } else {
            var is_last_day = FALSE
        }
        return
    }
    
    # Verify argument format
    match date "^([0-9]{8})$" ${SUBARG_1}
    if (${date.STATUS} != MATCH) {
        print Error: the provided argument is not in yyyyMMdd format
        terminate with error
    }
	
    # Get the day portion of the argument    
    match day "^[0-9]{6}([0-9]{2})$" ${SUBARG_1}
    var day_to_check = ${day.RESULT}

	# Get the yyyyMM portion of the argument
    match yyyyMM "^([0-9]{6})" ${SUBARG_1}
    var month = ${yyyyMM.RESULT}
	
    get_last_day_of ${month} as last_day
	
    if (${last_day} == ${day_to_check}) {
        var is_last_day = TRUE
    } else {
        var is_last_day = FALSE
    }
}
    
    
PreviousforeachNextgosub

Last updated 6 years ago

Was this helpful?