Purpose
We want to determine the first and the last day of the current, next or previous month.

This is useful, for example, for reporting purposes where you need to select the right time interval

We use GuiXT string and date operations:

// Determine first and last day of this month /next month /previous month

Set V[k] 1 // 1=next month, 0=this month, -1=previous month


// Use the GuiXT notation today_M and today_Y for current month and year

Set V[M] "&V[today_M]"

Set V[Y] "&V[today_Y]"


// add month offset

Set V[M] "&V[M]" + &V[k]

if V[M=13]

  Set V[M] "01"

  Set V[Y] &V[Y] + 1

else

  if V[M=0]

    Set V[M] "12"

    Set V[Y] &V[Y] - 1

  endif

endif


// "01" instead of "1" etc.

Set V[M](1-2) "0&V[M]" -alignright


// First day of month

Set V[from] "01.&V[M].&V[Y]"


// calculate last day of month

// build first day of next month then subtract 1 day

Set V[M] "&V[M]" + 1

if V[M=13]

  Set V[M] "01"

  Set V[Y] &V[Y] + 1

endif


// "01" instead of "1" etc.

Set V[M](1-2) "0&V[M]" -alignright

Set V[to] "01.&V[M].&V[Y]"

Set V[to] "&V[to]" - 1


// Now V[to] is the first day and V[from] last day

// of this/next/previous month

// Optionally:

// if necessary change the dates from format dd.mm.yyyy to correct user format

// Attention: in this case a valid RFC user/password is needed in GuiXT profile

Set V[diff] "&V[from]" - "&V[today_d.m.y]"

Set V[from] "&V[today+&V[diff]_user]"

Set V[diff] "&V[to]" - "&V[today_d.m.y]"

Set V[to] "&V[today+&V[diff]_user]"

Components
InputAssistant