Convert Date: Need code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2024 09:46 PM - edited 09-12-2024 09:51 PM
Hello all,
I need to convert today’s date to Julian date.
for ex: 13 sep 2024, in julian date it would be 24257.
then i need to append 0001 as suffix to this julian number.
final output = 242570001.
is it possible to run a loop and increment this number by 1 based on a count value provided in one of the catalog variables.
i am creating a flow. In the flow input would be the count variable from cat item. Then the script logic will calculate the numbers above in an array and then store them in an output variable on cat item.
please advise
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2024 10:52 PM - edited 09-13-2024 12:20 AM
BOT sample code and make changes as per your use case
once you get JulianDate format
var count = parseInt(current.variables.count_variable, 10); // Get count from catalog variable
var incrementedValue = incrementJulianNumber(count);
gs.print('value'+ incrementedValue);
function incrementJulianNumber(count) {
var baseJulian = getJulianDate(); // 24257
var suffix = '0001';
var baseNumber = parseInt(baseJulian + suffix, 10);
return baseNumber + count;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2024 12:06 AM
This does not work and throwing invalid object error. Chat gpt codes usually dont work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2024 04:08 AM - edited 09-13-2024 04:14 AM
Please Refer the below code and append your suffix
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2024 06:38 AM
Hi Sanjay, this is not returning correct value.
when i ran this in background scripts it returned
Julian Date : 2460596.5
I am expecting 24257 for today's date.