Hi Experts,
Can we get day from current date $.now in Workflow?
We need to fetch the day and do some evaluations in Workflow, let us know if its feasible?
Regards
Aditi
Hi Experts,
Can we get day from current date $.now in Workflow?
We need to fetch the day and do some evaluations in Workflow, let us know if its feasible?
Regards
Aditi
Hi Aditi.
$.now()
produces a timestamp in the following format: yyyy-mm-ddThh:mm:ssZ
. An actual value will look like this: 2023-08-22T19:28:38.698Z
. You can get the current day of the month by using the substring operator in your define variable step. Set the “Starts From” value to 8, and the “Length” to 2.
That will produce a variable that will just have the day of the month. So for a date of 2023-08-22T19:28:38.698Z
, the variable will produce the value 22
.
Thanks for the response, but I was looking for week day for example Monday or Tuesday etc.
Can we format the date in Workflow to get exact day of the week.
You can’t get day of week from native workflow actions at this time. You can provide that as feedback by clicking on the feedback button in the main workflow page.
However, you can use the Time API, which is a free web service that provides time functions. It has an endpoint that will get details about the current time in the timezone of your choice. For example, running a GET request at this endpoint will return the following payload:
GET https://timeapi.io/api/time/current/zone?timeZone=America/New_York
{
"year": 2023,
"month": 8,
"day": 23,
"hour": 8,
"minute": 51,
"seconds": 9,
"milliSeconds": 785,
"dateTime": "2023-08-23T08:51:09.785044",
"date": "08/23/2023",
"time": "08:51",
"timeZone": "America/New_York",
"dayOfWeek": "Wednesday",
"dstActive": true
}
As you can see, it provides the dayOfWeek
, which you can then use in subsequent actions. Just configure an HTTP Request with no authentication and use the URL endpoint provided above to get the current time for your timezone.
Then you can use this JSONpath to reference the day of week in subsequent actions.
$.hTTPRequest.body.dayOfWeek
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.