How to convert array value into getbyformat

Elakkiya A
Tera Contributor

I have tried the below code and it's not working with the array. Showing as undefined

var gValue = rel.begin.getDisplayValue();
var dateTime = gValue.split(' ');
    var date = dateTime[0];
    var niceTime = date.getByFormat('EEEE dd MMMM YYYY');
6 REPLIES 6

Community Alums
Not applicable

Hi @Elakkiya A ,

is the format you are asking is correct? " ('EEEE dd MMMM YYYY')  "

What is EEEE here?

It should be DD MM YYYY

Maik Skoddow
Tera Patron
Tera Patron

Hi @Elakkiya A 

there are several issues in your script. You cannot perform method getByFormat() on a string type, but date is of type string in your script. Furthermore getbyFormat is only defined for the GlideDate() API.

 

Therefore the following script is working fine

 

MaikSkoddow_0-1705980387806.png

 

For your script you probably have to replace line 5 with (unfortunately you did not explain what rel.begin is)

 

gdDate.setValue(rel.begin);

 

Maik

Elakkiya A
Tera Contributor

Hi @Maik Skoddow,

 

I am trying to getDisplayValue of a field which is the Date and timeScreenshot 2024-01-23 090548.png

Here I got the date alone by using that split condition. Now I need that date in this format EEEE dd MMMM YYYY. Is that possible?

Because If you use getValue instead of getDisplayValue for the begin field it's getting the previous date.

 

Thanks,

Hi @Elakkiya A 

I already provided the solution. You just have to take my code and adopt accordingly. So what is the issue?

Maik