JS RegEX operation on getNewNameData.item.create

What am I doing wrong here?
I am trying to apply a STRING.match(RegX_String) method.
The string I am wanting to match is this property:
getNewNameData.item.create
It prints to output like it is a string.
But typeof operator tells me it is an object.
thanks......

// From
// Scr_Kanwal_Onedrive_Photo_001_Add_Screenshot_js
//
function OnGetNewName(getNewNameData)
{
    strCreateDateTime = getNewNameData.item.create;
	DOpus.Output("000-0100 StrCreateDateTime BEFORE:     :" + strCreateDateTime);

	var item = getNewNameData.item;
	//                   DayOfWeek
    var regex_CDTime = /^(.{3}).*$/;

	DOpus.Output("000-0110 typeof strCreateDateTime      :" + typeof strCreateDateTime);
	
    var matched = strCreateDateTime.match(regex_CDTime);
//  var matched = str(strCreateDateTime).match(regex_CDTime);

	

}

Looks like you're trying to apply a regex to a Date object, which doesn't make sense. Regex are applied to strings, not dates.

If you want the day name, the Date can give it to you directly, either through the wday property or the Format method.

1 Like

And so it is!
Thanks Leo! Do you never sleep??

// Scr_CreateDateTimePrefixPhotos_004_Date_Object
//
function OnGetNewName(getNewNameData)
{
    strCreateDateTime = getNewNameData.item.create;
	DOpus.Output("000-0100 StrCreateDateTime             :" + strCreateDateTime);
	DOpus.Output("000-0100 StrCreateDateTime.year        :" + strCreateDateTime.year);
	DOpus.Output("000-0100 StrCreateDateTime.month       :" + strCreateDateTime.month);
	DOpus.Output("000-0100 StrCreateDateTime.day         :" + strCreateDateTime.day);
	DOpus.Output("000-0100 StrCreateDateTime.hour        :" + strCreateDateTime.hour);
	DOpus.Output("000-0100 StrCreateDateTime.min         :" + strCreateDateTime.min);
	DOpus.Output("000-0100 StrCreateDateTime.sec         :" + strCreateDateTime.sec);
}