If you substract the current day-of-the month from the current date in $horolog format, you will end up with the first day of the current month in $horolog format :
Write $horolog - $zdate($horolog, 4) + 1
If your date is in another format, convert it using $zdateh/$zdate, see also :
If you meant that you want to get the day (name/value) from the date then try $zdate(datevalue,dayformat) where datevalue is in $h format and dayformat is 10 for number of day in week, 11 for short day name, 12 for full day name.
check out the docs about $zdate , $zdateh, $systm.sql.datepart for more info about working with dates.
What do you mean?
If you have month and year just add 01 and produce the date.
If you substract the current day-of-the month from the current date in $horolog format, you will end up with the first day of the current month in $horolog format :
Write $horolog - $zdate($horolog, 4) + 1
If your date is in another format, convert it using $zdateh/$zdate, see also :
http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...
and
http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...
Looks a bit baffling at first, but what a beauty in that expression!
Just a hint, I would take $ZD($h,2). For today, my development system (and systems at customers site) shows:
Write $horolog - $zdate($horolog, 4) + 1 --> 65925.93 Write $zdate($horolog,4) --> 20.07.2021 Write $horolog - $zdate($horolog, 2) + 1 --> 65926 // expected value
Later, this value (65925.93), as a $zdate() argument, gives you an <ILLEGAL VALUE>
For $zdate($horolog,4), the link you provided says:
If you meant that you want to get the day (name/value) from the date then try $zdate(datevalue,dayformat) where datevalue is in $h format and dayformat is 10 for number of day in week, 11 for short day name, 12 for full day name.
check out the docs about $zdate , $zdateh, $systm.sql.datepart for more info about working with dates.