I am getting the date in DateFormat as mentioned below
2023-02-09 16:26:07.000
I would need date in this format for ex: 20230209 (YYYYMMDD)format.
Can you help me out over here ?
Solved! Go to Solution.
Hello,
It all depends on what your dataset looks like.
If you have an infotable you'll need to loop through it and format each row at a time.
If you are fetching the data from a database you could do the formatting in SQL instead so you don't waste resources looping.
If you only have one value, which is this "CompleteData.ldate", then your code should look like:
let yourCSVColumnName = dateFormat(CompleteData.ldate, "YYYYMMDD");
The dateFormat function takes two arguments, one is your date variable and the other is the date format you want.
However, as I do not know what type your date is in, you can try to do this first:
let datetime = parseDate("2023-02-05 16:26:07.00", "yyyy-MM-dd HH:mm:ss.SSS");
This will turn a string date into a datetime and you can then pass it into the dateFormat function:
result = dateFormat(datetime, "YYYYMMDD");
Hello,
Where do you need this date format?
In a mashup? If so, in what widget?
Regards,
Jens
I have a column named Date in csv file .I would need the date in csv file
Hello,
Okay, then you should be able to use the "dateFormat" function:
Thank you.
instead of new Date() I have to pass finalResult
finalResult=CompleteData.ldate; which is in DateFormat(2023-02-05 16:26:07.00)
which is not working.
Hello,
It all depends on what your dataset looks like.
If you have an infotable you'll need to loop through it and format each row at a time.
If you are fetching the data from a database you could do the formatting in SQL instead so you don't waste resources looping.
If you only have one value, which is this "CompleteData.ldate", then your code should look like:
let yourCSVColumnName = dateFormat(CompleteData.ldate, "YYYYMMDD");
The dateFormat function takes two arguments, one is your date variable and the other is the date format you want.
However, as I do not know what type your date is in, you can try to do this first:
let datetime = parseDate("2023-02-05 16:26:07.00", "yyyy-MM-dd HH:mm:ss.SSS");
This will turn a string date into a datetime and you can then pass it into the dateFormat function:
result = dateFormat(datetime, "YYYYMMDD");