- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 09:33 AM
Hi All,
having a requirement that need to convert the data format from dd-MM-yyyy to dd/MM/yyyy on the flow designer
by the below script in the flow designer by flow variables
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 09:43 AM
var dt = gs.nowDateTime();
var parts = dt.split('-');
var day = parts[0];
var month = parts[1];
var year = parts[2];
var formattedDate = day + '/' + month + '/' + year;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 10:38 AM
Hi @jMarshal
The script you suggested is working
var gd =new GlideDate();
var dt = gs.nowDateTime();
dt = dt.toString().split(" ")[0];
var parts = dt.split('-');
var day = parts[0];
var month = gd.getMonth();
month = month.toString();
month = "0" + month;
month = month.slice(-2);
var year = gd.getYear();
var formattedDate = day + '/' + month + '/' + year;
return formattedDate;
in the above script i changed for year then it completely retrieving the value as required
20/06/2023.
Thank You @jMarshal .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 01:21 PM
I think this has to do with your default date format on your instance...by default, "getMonth()" returns a numerical value for the current month, if you have a different setting, it might be conflicting - which is why you see "NaN" (Not a Number).
You can try this...it might work:
var gd =new GlideDate();
var dt = gs.nowDateTime();
dt = dt.toString().split(" ")[0];
var parts = dt.split('-');
var day = parts[0];
var month = gd.getMonth();
var year = parts[2];
var formattedDate = day + '/' + month + '/' + year;
return formattedDate;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 11:35 PM
Hi @jMarshal
we are almost there,
the current date is populating but required some changes on the month and the year.
we need to populate date dd- 20 , MM- 06 - year - 2023
i.e,. 20/06/2023
any suggestions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 06:58 AM
OK - how about this...?
var gd =new GlideDate();
var dt = gs.nowDateTime();
dt = dt.toString().split(" ")[0];
var parts = dt.split('-');
var day = parts[0];
var month = gd.getMonth();
month = month.toString();
month = "0" + month;
month = month.slice(-2);
var year = parts[2];
var formattedDate = day + '/' + month + '/' + year;
return formattedDate;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2023 10:38 AM
Hi @jMarshal
The script you suggested is working
var gd =new GlideDate();
var dt = gs.nowDateTime();
dt = dt.toString().split(" ")[0];
var parts = dt.split('-');
var day = parts[0];
var month = gd.getMonth();
month = month.toString();
month = "0" + month;
month = month.slice(-2);
var year = gd.getYear();
var formattedDate = day + '/' + month + '/' + year;
return formattedDate;
in the above script i changed for year then it completely retrieving the value as required
20/06/2023.
Thank You @jMarshal .