Aylık arşivler: Haziran 2019

Sap BO Lumira Designer tarih fonksiyonları (date functions)

Sap BO Lumira Designer’da (eski adı Sap BO Design Studio) Date (DateObject) (UTC) veri tipi geldi. Global değişkenler (global variables) Date veri tipinde tanımlanamıyorlar, Date objesi kod bloğu içinde tanımlanabiliyor/kullanılabiliyor.

Date objesi createUTC ile oluşturulurken aylar 1-12 arasında değil 0-11 arasında tanımlanıyor.

Date objesinin getUTCDay fonksiyonu haftanın kaçıncı günü olduğunu döndürüyor. Dönüş değerleri 0-6 arasında, 0 Pazar, 6 Cumartesi.

Amaç içinde bulunulan haftanın ilk gününü (pazartesi) bulmak. İlk yöntem Date objesinin valueOf fonksiyonunu farketmeden önce yazdığım/geliştirdiğim yöntem. İkinci yöntem (doğru, kolay, kısa, olması gereken yöntem) valueOf fonksiyonu ile hesapladığım yöntem.

lumira_designer__date_functions__get_week_start__first_method.txt
lumira_designer__date_functions__get_week_start__second_method.txt

---------------------------------------
---------------------------------------

LIB_DATE.get_current_week_start()

var day_of_week_0 = [1,2,3,4,5,6];
var day_of_week_1 = [0];
day_of_week_1.pop();
var day_of_week_2 = [1];
var day_of_week_3 = [1,2];
var day_of_week_4 = [1,2,3];
var day_of_week_5 = [1,2,3,4];
var day_of_week_6 = [1,2,3,4,5];
var day_of_week_temp = [0];
day_of_week_temp.pop();

var lv_today_YYYYMMDD = APPLICATION.getInfo().dateNowInternalFormat;

var lv_year_YYYY = Convert.subString(lv_today_YYYYMMDD, 0, 4);
var lv_month_MM = Convert.subString(lv_today_YYYYMMDD, 4, 6);
var lv_day_DD = Convert.subString(lv_today_YYYYMMDD, 6, 8);

var lv_year_int_YYYY = Convert.stringToInt(lv_year_YYYY);
var lv_month_int_MM = Convert.stringToInt(lv_month_MM);
var lv_day_int_DD = Convert.stringToInt(lv_day_DD);

var lv_today_DATE = Date.createUTC(lv_year_int_YYYY, lv_month_int_MM-1, lv_day_int_DD); // UTC months 0-11

if ( lv_today_DATE.getUTCDay() == 1 ) { // 0-6 Monday
	day_of_week_temp = day_of_week_1;
} else if ( lv_today_DATE.getUTCDay() == 2 ) { // 0-6 Tuesday
	day_of_week_temp = day_of_week_2;
} else if ( lv_today_DATE.getUTCDay() == 3 ) { // 0-6 Wednesday
	day_of_week_temp = day_of_week_3;
} else if ( lv_today_DATE.getUTCDay() == 4 ) { // 0-6 Thursday
	day_of_week_temp = day_of_week_4;
} else if ( lv_today_DATE.getUTCDay() == 5 ) { // 0-6 Friday
	day_of_week_temp = day_of_week_5;
} else if ( lv_today_DATE.getUTCDay() == 6 ) { // 0-6 Saturday
	day_of_week_temp = day_of_week_6;
} else if ( lv_today_DATE.getUTCDay() == 0 ) { // 0-6 Sunday
	day_of_week_temp = day_of_week_0;
}
day_of_week_temp.forEach(function(elm, ind) {
	lv_today_YYYYMMDD = LIB_DATE.get_previous_day(lv_today_YYYYMMDD);
});

var lv_current_week_start_YYYYMMDD = lv_today_YYYYMMDD;

return lv_current_week_start_YYYYMMDD;

---------------------------------------
---------------------------------------

LIB_DATE.get_previous_day(p_date(String))

var lv_today_YYYYMMDD = p_date;

var lv_year_YYYY = Convert.subString(lv_today_YYYYMMDD, 0, 4);
var lv_month_MM = Convert.subString(lv_today_YYYYMMDD, 4, 6);
var lv_day_DD = Convert.subString(lv_today_YYYYMMDD, 6, 8);

var lv_year_int = Convert.stringToInt(lv_year_YYYY);
var lv_month_int = Convert.stringToInt(lv_month_MM);
var lv_day_int = Convert.stringToInt(lv_day_DD);

var lv_previous_day = "";

if (lv_day_int != 1) {
	lv_previous_day = lv_year_YYYY + lv_month_MM + LIB_DATE.get_two_digit_month_or_day(lv_day_int-1);
} else {
	if (lv_month_int != 1) { // go previous month
		lv_previous_day = lv_year_YYYY + LIB_DATE.get_two_digit_month_or_day(lv_month_int-1) + LIB_DATE.get_two_digit_month_or_day(LIB_DATE.get_previous_month_days(p_date));
	} else { // go previous month and year
		lv_previous_day = Convert.floatToString(lv_year_int-1,"###0") + LIB_DATE.get_two_digit_month_or_day(12) + LIB_DATE.get_two_digit_month_or_day(LIB_DATE.get_previous_month_days(p_date));
	}
}

return lv_previous_day;

---------------------------------------
---------------------------------------

LIB_DATE.get_previous_month_days(p_date(String))

var lv_previous_month_start_YYYYMMDD = LIB_DATE.get_previous_month_start(p_date);

var lv_year_YYYY = Convert.subString(lv_previous_month_start_YYYYMMDD, 0, 4);
var lv_month_MM = Convert.subString(lv_previous_month_start_YYYYMMDD, 4, 6);
var lv_day_DD = Convert.subString(lv_previous_month_start_YYYYMMDD, 6, 8);

var lv_year_int_YYYY = Convert.stringToInt(lv_year_YYYY);
var lv_month_int_MM = Convert.stringToInt(lv_month_MM);
var lv_day_int_DD = Convert.stringToInt(lv_day_DD);

var lv_previous_month_days = 0;

if (lv_month_MM=="01" || lv_month_MM=="03" || lv_month_MM=="05" || lv_month_MM=="07" || lv_month_MM=="08" || lv_month_MM=="10" || lv_month_MM=="12") {
	lv_previous_month_days = 31;
} else if (lv_month_MM=="04" || lv_month_MM=="06" || lv_month_MM=="09" || lv_month_MM=="11") {
	lv_previous_month_days = 30;
} else  if (lv_month_MM=="02") {
	if ( Math.floor(lv_year_int_YYYY/4)*4 == lv_year_int_YYYY ) {
		// leap year
		lv_previous_month_days = 29;
	} else {
		lv_previous_month_days = 28;
	}
}

return lv_previous_month_days;

---------------------------------------
---------------------------------------

LIB_DATE.get_today()

return APPLICATION.getInfo().dateNowInternalFormat;

---------------------------------------
---------------------------------------

LIB_DATE.get_two_digit_month_or_day(p_day_or_month(int))

if (p_day_or_month < 10) {
	return "0"+Convert.floatToString(p_day_or_month,"#0");
} else {
	return Convert.floatToString(p_day_or_month,"#0");
}

---------------------------------------
---------------------------------------

LIB_DATE.get_week_start(p_date(String))

var day_of_week_0 = [1,2,3,4,5,6];
var day_of_week_1 = [0];
day_of_week_1.pop();
var day_of_week_2 = [1];
var day_of_week_3 = [1,2];
var day_of_week_4 = [1,2,3];
var day_of_week_5 = [1,2,3,4];
var day_of_week_6 = [1,2,3,4,5];
var day_of_week_temp = [0];
day_of_week_temp.pop();

var lv_today_YYYYMMDD = p_date;

var lv_year_YYYY = Convert.subString(lv_today_YYYYMMDD, 0, 4);
var lv_month_MM = Convert.subString(lv_today_YYYYMMDD, 4, 6);
var lv_day_DD = Convert.subString(lv_today_YYYYMMDD, 6, 8);

var lv_year_int_YYYY = Convert.stringToInt(lv_year_YYYY);
var lv_month_int_MM = Convert.stringToInt(lv_month_MM);
var lv_day_int_DD = Convert.stringToInt(lv_day_DD);

var lv_today_DATE = Date.createUTC(lv_year_int_YYYY, lv_month_int_MM-1, lv_day_int_DD); // UTC months 0-11

if ( lv_today_DATE.getUTCDay() == 1 ) { // 0-6 Monday
	day_of_week_temp = day_of_week_1;
} else if ( lv_today_DATE.getUTCDay() == 2 ) { // 0-6 Tuesday
	day_of_week_temp = day_of_week_2;
} else if ( lv_today_DATE.getUTCDay() == 3 ) { // 0-6 Wednesday
	day_of_week_temp = day_of_week_3;
} else if ( lv_today_DATE.getUTCDay() == 4 ) { // 0-6 Thursday
	day_of_week_temp = day_of_week_4;
} else if ( lv_today_DATE.getUTCDay() == 5 ) { // 0-6 Friday
	day_of_week_temp = day_of_week_5;
} else if ( lv_today_DATE.getUTCDay() == 6 ) { // 0-6 Saturday
	day_of_week_temp = day_of_week_6;
} else if ( lv_today_DATE.getUTCDay() == 0 ) { // 0-6 Sunday
	day_of_week_temp = day_of_week_0;
}
day_of_week_temp.forEach(function(elm, ind) {
	lv_today_YYYYMMDD = LIB_DATE.get_previous_day(lv_today_YYYYMMDD);
});

var lv_week_start_YYYYMMDD = lv_today_YYYYMMDD;

return lv_week_start_YYYYMMDD;

---------------------------------------
---------------------------------------
---------------------------------------
---------------------------------------

LIB_DATE.get_current_week_start_2()

var lv_today_YYYYMMDD = APPLICATION.getInfo().dateNowInternalFormat;

var lv_year_YYYY = Convert.subString(lv_today_YYYYMMDD, 0, 4);
var lv_month_MM = Convert.subString(lv_today_YYYYMMDD, 4, 6);
var lv_day_DD = Convert.subString(lv_today_YYYYMMDD, 6, 8);

var lv_year_int_YYYY = Convert.stringToInt(lv_year_YYYY);
var lv_month_int_MM = Convert.stringToInt(lv_month_MM);
var lv_day_int_DD = Convert.stringToInt(lv_day_DD);

var lv_today_DATE = Date.createUTC(lv_year_int_YYYY, lv_month_int_MM-1, lv_day_int_DD); // UTC months 0-11

var lv_current_week_start_YYYYMMDD = "";

if ( lv_today_DATE.getUTCDay() == 1 ) { // 0-6 Monday
	lv_current_week_start_YYYYMMDD = LIB_DATE.get_relative_date(lv_today_YYYYMMDD,0);
} else if ( lv_today_DATE.getUTCDay() == 2 ) { // 0-6 Tuesday
	lv_current_week_start_YYYYMMDD = LIB_DATE.get_relative_date(lv_today_YYYYMMDD,-1);
} else if ( lv_today_DATE.getUTCDay() == 3 ) { // 0-6 Wednesday
	lv_current_week_start_YYYYMMDD = LIB_DATE.get_relative_date(lv_today_YYYYMMDD,-2);
} else if ( lv_today_DATE.getUTCDay() == 4 ) { // 0-6 Thursday
	lv_current_week_start_YYYYMMDD = LIB_DATE.get_relative_date(lv_today_YYYYMMDD,-3);
} else if ( lv_today_DATE.getUTCDay() == 5 ) { // 0-6 Friday
	lv_current_week_start_YYYYMMDD = LIB_DATE.get_relative_date(lv_today_YYYYMMDD,-4);
} else if ( lv_today_DATE.getUTCDay() == 6 ) { // 0-6 Saturday
	lv_current_week_start_YYYYMMDD = LIB_DATE.get_relative_date(lv_today_YYYYMMDD,-5);
} else if ( lv_today_DATE.getUTCDay() == 0 ) { // 0-6 Sunday
	lv_current_week_start_YYYYMMDD = LIB_DATE.get_relative_date(lv_today_YYYYMMDD,-6);
}

return lv_current_week_start_YYYYMMDD;

---------------------------------------
---------------------------------------

LIB_DATE.get_relative_date(p_date(String),p_n(int))

var lv_today_YYYYMMDD = p_date;

var lv_year_YYYY = Convert.subString(lv_today_YYYYMMDD, 0, 4);
var lv_month_MM = Convert.subString(lv_today_YYYYMMDD, 4, 6);
var lv_day_DD = Convert.subString(lv_today_YYYYMMDD, 6, 8);

var lv_year_int_YYYY = Convert.stringToInt(lv_year_YYYY);
var lv_month_int_MM = Convert.stringToInt(lv_month_MM);
var lv_day_int_DD = Convert.stringToInt(lv_day_DD);

var lv_today_DATE = Date.createUTC(lv_year_int_YYYY, lv_month_int_MM-1, lv_day_int_DD); // UTC months 0-11

var lv_today_utc_value = lv_today_DATE.valueOf();

var lv_relative_utc_value = lv_today_utc_value + (p_n * 24 * 60 * 60 * 1000);

var lv_relative_date_DATE = Date.createUTC(1970, 0, 1, 0, 0, 0, lv_relative_utc_value);

var lv_relative_date_YYYYMMDD = lv_relative_date_DATE.toSapDateString();

return lv_relative_date_YYYYMMDD;

---------------------------------------
---------------------------------------

LIB_DATE.get_today()

return APPLICATION.getInfo().dateNowInternalFormat;

---------------------------------------
---------------------------------------

LIB_DATE.get_two_digit_month_or_day(p_day_or_month(int))

if (p_day_or_month < 10) {
	return "0"+Convert.floatToString(p_day_or_month,"#0");
} else {
	return Convert.floatToString(p_day_or_month,"#0");
}

---------------------------------------
---------------------------------------

LIB_DATE.get_week_start_2(p_date(String))

var lv_today_YYYYMMDD = p_date;

var lv_year_YYYY = Convert.subString(lv_today_YYYYMMDD, 0, 4);
var lv_month_MM = Convert.subString(lv_today_YYYYMMDD, 4, 6);
var lv_day_DD = Convert.subString(lv_today_YYYYMMDD, 6, 8);

var lv_year_int_YYYY = Convert.stringToInt(lv_year_YYYY);
var lv_month_int_MM = Convert.stringToInt(lv_month_MM);
var lv_day_int_DD = Convert.stringToInt(lv_day_DD);

var lv_today_DATE = Date.createUTC(lv_year_int_YYYY, lv_month_int_MM-1, lv_day_int_DD); // UTC months 0-11

var lv_current_week_start_YYYYMMDD = "";

if ( lv_today_DATE.getUTCDay() == 1 ) { // 0-6 Monday
	lv_current_week_start_YYYYMMDD = LIB_DATE.get_relative_date(lv_today_YYYYMMDD,0);
} else if ( lv_today_DATE.getUTCDay() == 2 ) { // 0-6 Tuesday
	lv_current_week_start_YYYYMMDD = LIB_DATE.get_relative_date(lv_today_YYYYMMDD,-1);
} else if ( lv_today_DATE.getUTCDay() == 3 ) { // 0-6 Wednesday
	lv_current_week_start_YYYYMMDD = LIB_DATE.get_relative_date(lv_today_YYYYMMDD,-2);
} else if ( lv_today_DATE.getUTCDay() == 4 ) { // 0-6 Thursday
	lv_current_week_start_YYYYMMDD = LIB_DATE.get_relative_date(lv_today_YYYYMMDD,-3);
} else if ( lv_today_DATE.getUTCDay() == 5 ) { // 0-6 Friday
	lv_current_week_start_YYYYMMDD = LIB_DATE.get_relative_date(lv_today_YYYYMMDD,-4);
} else if ( lv_today_DATE.getUTCDay() == 6 ) { // 0-6 Saturday
	lv_current_week_start_YYYYMMDD = LIB_DATE.get_relative_date(lv_today_YYYYMMDD,-5);
} else if ( lv_today_DATE.getUTCDay() == 0 ) { // 0-6 Sunday
	lv_current_week_start_YYYYMMDD = LIB_DATE.get_relative_date(lv_today_YYYYMMDD,-6);
}

return lv_current_week_start_YYYYMMDD;

---------------------------------------
---------------------------------------

Sap Hana eş zamanlı yazma işlemlerinde kilitleme yöntemi

Sap Hana veri tabanında eş zamanlı işlemlerin nasıl idare edildiğini (kontrol edildiğini) anlatan güzel bir yazı: SAP HANA Concurrency Control

Amacım Sap Hana’nın yazma işlemlerinde tablo bazlı mı yoksa satır bazlı mı kilitleme (table level or row level locking) yaptığını öğrenmekti. Cevap satır bazlıymış. “Write Locks and Deadlock” kısmında yer alan “the SAP HANA database uses exclusive write locks at row level” ifadesi.

Sap BO Design Studio Tarih Fonksiyonları (Date Functions)

Sap BO Design Studio’da (1.x) tarih hesaplamaları veri kaynaklarında yapılması gerekiyor. Design Studio’da tarih fonksiyonları yer almıyor. Bu ihtiyaç için Karol Kalisz Design Studio Sdk ile ücretsiz ve açık kaynak Simple Date Object Component @github geliştirmiş.

Sap BO Lumira Designer’da (2.x) tarih hesaplamaları için Date (DateObject) dahili olarak yer alıyor. Global değişken tipi olarak seçilemiyor ama kod bloğunda var d1 = Date.createNow(); şeklinde kullanılabiliyor.

Bu Design Studio eklentisini kullanmadan tarih hesaplamalarını yapmak için yazdığım fonksiyonlar: (Burada en önemlisi get_previous_day ile önceki güne gitme fonksiyonu, n elemanlı dizi tanımlayıp n gün öncesine gidilebiliyor. WebI deki RelativeDate gibi)

design_studio_lib_date.txt

---------------------------------------
---------------------------------------

Global Variables
----------------

gv_date_current_month_array(String)(Array)
gv_date_current_month_concatenated_string(String)
gv_date_current_quarter_array(String)(Array)
gv_date_current_quarter_concatenated_string(String)
gv_date_current_year_array
gv_date_current_year_concatenated_string
gv_date_full_array
gv_date_full_concatenated_string
gv_date_full_not_concatenated_string
gv_date_last_month_array
gv_date_last_month_concatenated_string
gv_date_yesterday_array
gv_date_yesterday_concatenated_string

---------------------------------------
---------------------------------------

LIB_DATE
--------

---------------------------------------
---------------------------------------

LIB_DATE.get_current_month_start()

var lv_today_YYYYMMDD = APPLICATION.getInfo().dateNowInternalFormat;

var lv_year_YYYY = Convert.subString(lv_today_YYYYMMDD, 0, 4);
var lv_month_MM = Convert.subString(lv_today_YYYYMMDD, 4, 6);
var lv_day_DD = Convert.subString(lv_today_YYYYMMDD, 6, 8);

var lv_current_month_start_YYYYMMDD = lv_year_YYYY+lv_month_MM+"01";

return lv_current_month_start_YYYYMMDD;

---------------------------------------
---------------------------------------

LIB_DATE.get_current_quarter_start()

var lv_today_YYYYMMDD = APPLICATION.getInfo().dateNowInternalFormat;

var lv_year_YYYY = Convert.subString(lv_today_YYYYMMDD, 0, 4);
var lv_month_MM = Convert.subString(lv_today_YYYYMMDD, 4, 6);
var lv_day_DD = Convert.subString(lv_today_YYYYMMDD, 6, 8);

var lv_current_quarter_start_YYYYMMDD = "";

if (lv_month_MM =="01" || lv_month_MM =="02" || lv_month_MM =="03") {
	lv_current_quarter_start_YYYYMMDD = lv_year_YYYY + "01" + "01";
} else if (lv_month_MM =="04" || lv_month_MM =="05" || lv_month_MM =="06") {
	lv_current_quarter_start_YYYYMMDD = lv_year_YYYY + "04" + "01";
} else if (lv_month_MM =="07" || lv_month_MM =="08" || lv_month_MM =="09") {
	lv_current_quarter_start_YYYYMMDD = lv_year_YYYY + "07" + "01";
} else if (lv_month_MM =="10" || lv_month_MM =="11" || lv_month_MM =="12") {
	lv_current_quarter_start_YYYYMMDD = lv_year_YYYY + "10" + "01";
}

return lv_current_quarter_start_YYYYMMDD;

---------------------------------------
---------------------------------------

LIB_DATE.get_current_year_start()

var lv_today_YYYYMMDD = APPLICATION.getInfo().dateNowInternalFormat;

var lv_year_YYYY = Convert.subString(lv_today_YYYYMMDD, 0, 4);
var lv_month_MM = Convert.subString(lv_today_YYYYMMDD, 4, 6);
var lv_day_DD = Convert.subString(lv_today_YYYYMMDD, 6, 8);

var lv_current_year_start_YYYYMMDD = lv_year_YYYY+"01"+"01";

return lv_current_year_start_YYYYMMDD;

---------------------------------------
---------------------------------------

LIB_DATE.get_current_year_start()

var lv_today_YYYYMMDD = APPLICATION.getInfo().dateNowInternalFormat;

var lv_year_YYYY = Convert.subString(lv_today_YYYYMMDD, 0, 4);
var lv_month_MM = Convert.subString(lv_today_YYYYMMDD, 4, 6);
var lv_day_DD = Convert.subString(lv_today_YYYYMMDD, 6, 8);

var lv_current_year_start_YYYYMMDD = lv_year_YYYY+"01"+"01";

return lv_current_year_start_YYYYMMDD;

---------------------------------------
---------------------------------------

LIB_DATE.get_last_month_start()

var lv_today_YYYYMMDD = APPLICATION.getInfo().dateNowInternalFormat;

var lv_year_YYYY = Convert.subString(lv_today_YYYYMMDD, 0, 4);
var lv_month_MM = Convert.subString(lv_today_YYYYMMDD, 4, 6);
var lv_day_DD = Convert.subString(lv_today_YYYYMMDD, 6, 8);

var lv_last_month_start_YYYYMMDD = "";

var lv_year_int = Convert.stringToInt(lv_year_YYYY);
var lv_month_int = Convert.stringToInt(lv_month_MM);
var lv_day_int = Convert.stringToInt(lv_day_DD);

if (lv_month_int==1) {
	lv_last_month_start_YYYYMMDD = Convert.floatToString(lv_year_int-1,"###0")+"12"+"01";
} else {
	lv_last_month_start_YYYYMMDD = lv_year_YYYY+LIB_DATE.get_two_digit_month_or_day(lv_month_int-1)+"01";
}

return lv_last_month_start_YYYYMMDD;

---------------------------------------
---------------------------------------

LIB_DATE.get_previous_day(p_date(String))

var lv_today_YYYYMMDD = p_date;

var lv_year_YYYY = Convert.subString(lv_today_YYYYMMDD, 0, 4);
var lv_month_MM = Convert.subString(lv_today_YYYYMMDD, 4, 6);
var lv_day_DD = Convert.subString(lv_today_YYYYMMDD, 6, 8);

var lv_year_int = Convert.stringToInt(lv_year_YYYY);
var lv_month_int = Convert.stringToInt(lv_month_MM);
var lv_day_int = Convert.stringToInt(lv_day_DD);

var lv_previous_day = "";

if (lv_day_int != 1) {
	lv_previous_day = lv_year_YYYY + lv_month_MM + LIB_DATE.get_two_digit_month_or_day(lv_day_int-1);
} else {
	if (lv_month_int != 1) { // go previous month
		lv_previous_day = lv_year_YYYY + LIB_DATE.get_two_digit_month_or_day(lv_month_int-1) + LIB_DATE.get_two_digit_month_or_day(LIB_DATE.get_previous_month_days(p_date));
	} else { // go previous month and year
		lv_previous_day = Convert.floatToString(lv_year_int-1,"###0") + LIB_DATE.get_two_digit_month_or_day(12) + LIB_DATE.get_two_digit_month_or_day(LIB_DATE.get_previous_month_days(p_date));
	}
}

return lv_previous_day;

---------------------------------------
---------------------------------------

LIB_DATE.get_previous_month_days(p_date(String))

var lv_previous_month_start_YYYYMMDD = LIB_DATE.get_previous_month_start(p_date);

var lv_year_YYYY = Convert.subString(lv_previous_month_start_YYYYMMDD, 0, 4);
var lv_month_MM = Convert.subString(lv_previous_month_start_YYYYMMDD, 4, 6);
var lv_day_DD = Convert.subString(lv_previous_month_start_YYYYMMDD, 6, 8);

var lv_year_int_YYYY = Convert.stringToInt(lv_year_YYYY);
var lv_month_int_MM = Convert.stringToInt(lv_month_MM);
var lv_day_int_DD = Convert.stringToInt(lv_day_DD);

var lv_previous_month_days = 0;

if (lv_month_MM=="01" || lv_month_MM=="03" || lv_month_MM=="05" || lv_month_MM=="07" || lv_month_MM=="08" || lv_month_MM=="10" || lv_month_MM=="12") {
	lv_previous_month_days = 31;
} else if (lv_month_MM=="04" || lv_month_MM=="06" || lv_month_MM=="09" || lv_month_MM=="11") {
	lv_previous_month_days = 30;
} else  if (lv_month_MM=="02") {
	if ( Math.floor(lv_year_int_YYYY/4)*4 == lv_year_int_YYYY ) {
		// leap year
		lv_previous_month_days = 29;
	} else {
		lv_previous_month_days = 28;
	}
}

return lv_previous_month_days;

---------------------------------------
---------------------------------------

LIB_DATE.get_previous_month_start(p_date(String))

var lv_date_YYYYMMDD = p_date;

var lv_year_YYYY = Convert.subString(lv_date_YYYYMMDD, 0, 4);
var lv_month_MM = Convert.subString(lv_date_YYYYMMDD, 4, 6);
var lv_day_DD = Convert.subString(lv_date_YYYYMMDD, 6, 8);

var lv_previous_month_start_YYYYMMDD = "";

var lv_year_int = Convert.stringToInt(lv_year_YYYY);
var lv_month_int = Convert.stringToInt(lv_month_MM);
var lv_day_int = Convert.stringToInt(lv_day_DD);

if (lv_month_int==1) {
	lv_previous_month_start_YYYYMMDD = Convert.floatToString(lv_year_int-1,"###0")+"12"+"01";
} else {
	lv_previous_month_start_YYYYMMDD = lv_year_YYYY+LIB_DATE.get_two_digit_month_or_day(lv_month_int-1)+"01";
}

return lv_previous_month_start_YYYYMMDD;

---------------------------------------
---------------------------------------

LIB_DATE.get_today()

return APPLICATION.getInfo().dateNowInternalFormat;

---------------------------------------
---------------------------------------

LIB_DATE.get_two_digit_month_or_day(p_day_or_month(int))

if (p_day_or_month < 10) {
	return "0"+Convert.floatToString(p_day_or_month,"#0");
} else {
	return Convert.floatToString(p_day_or_month,"#0");
}

---------------------------------------
---------------------------------------

LIB_DATE.get_year(p_date(String))

return Convert.subString(p_date, 0, 4);

---------------------------------------
---------------------------------------

LIB_DATE.get_year_month(p_date(String))

return Convert.subString(p_date, 0, 6);

---------------------------------------
---------------------------------------

LIB_DATE.get_year_quarter(p_date(String))

var lv_year_YYYY = Convert.subString(p_date, 0, 4);
var lv_month_MM = Convert.subString(p_date, 4, 6);
var lv_day_DD = Convert.subString(p_date, 6, 8);

var lv_year_quarter_YYYYQN = "";

if (lv_month_MM == "01" || lv_month_MM == "02" || lv_month_MM == "03") {
	lv_year_quarter_YYYYQN = lv_year_YYYY + "Q1";
} else if (lv_month_MM == "04" || lv_month_MM == "05" || lv_month_MM == "06") {
	lv_year_quarter_YYYYQN = lv_year_YYYY + "Q2";
} else if (lv_month_MM == "07" || lv_month_MM == "08" || lv_month_MM == "09") {
	lv_year_quarter_YYYYQN = lv_year_YYYY + "Q3";
} else if (lv_month_MM == "10" || lv_month_MM == "11" || lv_month_MM == "12") {
	lv_year_quarter_YYYYQN = lv_year_YYYY + "Q4";
}

return lv_year_quarter_YYYYQN;

---------------------------------------
---------------------------------------

LIB_DATE.initialize_date_arrays_for_filtering()

var lv_date_temp = "";
var lv_date_temp_formatted = "";

var lv_today_YYYYMMDD = LIB_DATE.get_today();
var lv_current_month_start_YYYYMMDD = LIB_DATE.get_current_month_start();
var lv_current_month_YYYYMM = LIB_DATE.get_year_month(lv_today_YYYYMMDD);
var lv_last_month_start_YYYYMMDD = LIB_DATE.get_last_month_start();
var lv_last_month_YYYYMM = LIB_DATE.get_year_month(lv_last_month_start_YYYYMMDD);
var lv_current_quarter_start_YYYYMMDD = LIB_DATE.get_current_quarter_start();
var lv_current_quarter_YYYYQN = LIB_DATE.get_year_quarter(lv_today_YYYYMMDD);
var lv_current_year_start_YYYYMMDD = LIB_DATE.get_current_year_start();
var lv_current_year_YYYY = LIB_DATE.get_year(lv_today_YYYYMMDD);

gv_date_full_concatenated_string = "";
gv_date_full_not_concatenated_string = "";
gv_date_current_month_concatenated_string = "";
gv_date_last_month_concatenated_string = "";
gv_date_current_quarter_concatenated_string = "";
gv_date_current_year_concatenated_string = "";

var lv_caldays_array = DS_DAYS.getMembers("DAY", 2000);

lv_caldays_array.forEach(function(sel, ind) {
	lv_date_temp = sel.internalKey;
	lv_date_temp_formatted = Convert.subString(lv_date_temp,4,6)+"/"+Convert.subString(lv_date_temp,6,8)+"/"+Convert.subString(lv_date_temp,0,4);
	gv_date_full_array.push(lv_date_temp);
	gv_date_full_concatenated_string = gv_date_full_concatenated_string + ";" + lv_date_temp_formatted;
	gv_date_full_not_concatenated_string = gv_date_full_not_concatenated_string + ";!" + lv_date_temp_formatted;
	// current month
	if ( lv_current_month_YYYYMM == LIB_DATE.get_year_month(lv_date_temp) ) {
		gv_date_current_month_array.push(lv_date_temp);
		gv_date_current_month_concatenated_string = gv_date_current_month_concatenated_string + ";" + lv_date_temp_formatted;
	}
	// last month
	if ( lv_last_month_YYYYMM == LIB_DATE.get_year_month(lv_date_temp) ) {
		gv_date_last_month_array.push(lv_date_temp);
		gv_date_last_month_concatenated_string = gv_date_last_month_concatenated_string + ";" + lv_date_temp_formatted;
	}
	// current quarter
	if ( lv_current_quarter_YYYYQN == LIB_DATE.get_year_quarter(lv_date_temp) ) {
		gv_date_current_quarter_array.push(lv_date_temp);
		gv_date_current_quarter_concatenated_string = gv_date_current_quarter_concatenated_string + ";" + lv_date_temp_formatted;
	}
	// current year
	if ( lv_current_year_YYYY == LIB_DATE.get_year(lv_date_temp) ) {
		gv_date_current_year_array.push(lv_date_temp);
		gv_date_current_year_concatenated_string = gv_date_current_year_concatenated_string + ";" + lv_date_temp_formatted;
	}
});

gv_date_full_concatenated_string = Convert.subString(gv_date_full_concatenated_string, 1); // lv_date_concatenation.length
gv_date_full_not_concatenated_string = Convert.subString(gv_date_full_not_concatenated_string, 1);
gv_date_current_month_concatenated_string = Convert.subString(gv_date_current_month_concatenated_string, 1);
gv_date_last_month_concatenated_string = Convert.subString(gv_date_last_month_concatenated_string, 1);
gv_date_current_quarter_concatenated_string = Convert.subString(gv_date_current_quarter_concatenated_string, 1);
gv_date_current_year_concatenated_string = Convert.subString(gv_date_current_year_concatenated_string, 1);

/*
if (gv_date_full_concatenated_string == "") {
	gv_date_full_concatenated_string = gv_date_full_not_concatenated_string;
}
if (gv_date_current_month_concatenated_string == "") {
	gv_date_current_month_concatenated_string = gv_date_full_not_concatenated_string;
}
if (gv_date_last_month_concatenated_string == "") {
	gv_date_last_month_concatenated_string = gv_date_full_not_concatenated_string;
}
if (gv_date_current_quarter_concatenated_string == "") {
	gv_date_current_quarter_concatenated_string = gv_date_full_not_concatenated_string;
}
if (gv_date_current_year_concatenated_string == "") {
	gv_date_current_year_concatenated_string = gv_date_full_not_concatenated_string;
}
*/

if (gv_date_full_concatenated_string == "") {
	gv_date_full_concatenated_string = "01/01/2100";
}
if (gv_date_current_month_concatenated_string == "") {
	gv_date_current_month_concatenated_string = "01/01/2100";
}
if (gv_date_last_month_concatenated_string == "") {
	gv_date_last_month_concatenated_string = "01/01/2100";
}
if (gv_date_current_quarter_concatenated_string == "") {
	gv_date_current_quarter_concatenated_string = "01/01/2100";
}
if (gv_date_current_year_concatenated_string == "") {
	gv_date_current_year_concatenated_string = "01/01/2100";
}

---------------------------------------
---------------------------------------