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
  • Details
  • Example

Was this helpful?

Export as PDF
  1. Data pipelines
  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
    }
}
Previousgenerate_jwtNextgosub

Last updated 5 years ago

Was this helpful?