- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 09:48 AM - edited 07-21-2023 10:06 AM
Hi All,
i am new to split function.
I want to separate date, month and year from dd-mm-yyyy format on catalog item and show just month at there.
there are 2 variables. one is date [dt] and second is show date[u_sd]. the requirement is: autopopulate date on show date variable and the date that is present on show date, it's month must be convert into name, like jan for 1 or march for 3 etc.
thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 11:19 AM
hello @DEV976 ,
write a onchange client script on first date field and try code like below.
you can do something like below:-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 06:19 AM - edited 07-25-2023 07:27 AM
Hello @DEV976
unction onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var months=["jan","feb","march","april","may","june","july","sep","october","november","december"];
newValue= newValue.split("-",[3]);
var month=newValue[1];
var name=(months[month-1]);
var dateM = newValue[2].split("");
var date2;
if((dateM[0]==0 || dateM[0]==2) && (dateM[1]==1)) {
date2= newValue[0]+"-"+name+"-"+newValue[2]+"st";
}
else if((dateM[0]==0 || dateM[0]==2)&& (dateM[1]==2) ){
date2= newValue[0]+"-"+name+"-"+newValue[2]+"nd";
}
else if((dateM[0]==0 || dateM[0]==2) && (dateM[1]==3) ){
date2= newValue[0]+"-"+name+"-"+newValue[2]+"rd";
}
else{
date2= newValue[0]+"-"+name+"-"+newValue[2]+"th";
}
g_form.setValue('u_date2',date2);
}
I have tried on my pdi, it is working fine.
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 06:35 AM
Hello @DEV976
Have you check the script which i shared??
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 06:40 AM
Hi @Samaksh Wani, i am checking
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 06:42 AM - edited 07-25-2023 06:42 AM
Hello @DEV976
add this line also :-
var dateM = newValue[0].split("");
By the way, i have updated the original post also.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 07:29 AM
Hello @DEV976
I have updated the script as per your requirement.
As per new Community rules, you can mark multiple solution as Accept.
Can you pls mark the script as response as Accept, it will help future readers to find correct response in the hierachy of conversation.
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh