Converting the date to the desired format

:us: Hello,

I am currently retrieving a date in the following format: “23 11:30 2024 اغسطس”. I would like to transform it into “23/08/2024”.

Could you please advise me on how to make this conversion using Make?

Thank you in advance for your help.

Best regards,


Bonjour,

Je récupère actuellement une date au format suivant : “23 11:30 2024 اغسطس”. Je souhaiterais la transformer en “23/08/2024”.

Pourriez-vous m’indiquer comment effectuer cette transformation en utilisant Make ?

Merci d’avance pour votre aide.

Cordialement,

Welcome to the Make community!

This is a great use-case for AI to perform.

You can do this with just a single module.

Here is an example using the FREE Groq AI module “Create a Chat Completion”:

Output

Screenshot_2024-08-26_200833

Module Export - quick import into your scenario

You can copy and paste this module export into your scenario. This will import the modules (with fields/settings/filters) shown in my screenshots above.

  1. Move your mouse over the line of code below. Copy the JSON by clicking the copy button on the right of the code, which looks like this:

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the editor.

  3. Click on each imported module and re-save it for validation. There may be some errors prompting you to remap some variables and connections.

JSON module export — paste this directly in your scenario

{"subflows":[{"flow":[{"id":286,"module":"groq:createJSONChatCompletion","version":1,"parameters":{"__IMTCONN__":2370769},"mapper":{"model":"llama-3.1-70b-versatile","systemPrompt":"You will receive possibly non-English dates, translate them, and extract them into JSON using the example format below.\n\nThe JSON should look like this:\n\n{\n  \"formatted_date\": \"31/12/2024\",\n  \"formatted_time\": \"11:59pm\",\n  \"military_time\": \"23:59\"\n}","userMessage":"23 11:30 2024 اغسطس"},"metadata":{"designer":{"x":2993,"y":-1387},"restore":{"parameters":{"__IMTCONN__":{"label":"My Groq API Key connection","data":{"scoped":"true","connection":"groq"}}},"expect":{"model":{"mode":"chose","label":"llama-3.1-70b-versatile"}}},"parameters":[{"name":"__IMTCONN__","type":"account:groq","label":"Connection","required":true}],"expect":[{"name":"model","type":"select","label":"Model","required":true},{"name":"systemPrompt","type":"text","label":"System Prompt","required":true},{"name":"userMessage","type":"text","label":"User Message","required":true},{"name":"max_tokens","type":"number","label":"Max tokens returned"},{"name":"temperature","type":"number","label":"Temperature"},{"name":"top_p","type":"number","label":"Top P"},{"name":"frequency_penalty","type":"number","label":"Frequency Penalty"},{"name":"seed","type":"number","label":"Seed"}]}}]}],"metadata":{"version":1}}

Note: Did you know you can reduce the size of blueprints and module export code like the above, using the Make Blueprint Scrubber?

Hope this helps! Let me know if there are any further questions or issues.

@samliew


P.S.: Did you know, the concepts of about 70% of questions asked on this forum are already covered in the Make Academy. Investing some effort into it will save you lots of time and frustration using Make later!

:us: Hello again,

I’m encountering an issue with the format of the dates I’m retrieving. Each time, the dates are in a different format, for example:

  • “23 11:30 2024 اغسطس”
  • “23 11:30 2024 مايو”
  • “26 11:30 2024 مايو”
  • “23 11:30 2024 يونيو”

The month can change each time and is sometimes in Arabic or another format. Could you please advise me on the best way to convert these dates into a standardized format, such as “DD/MM/YYYY”, in general?

Thank you in advance for your help.


rebonjour , Je rencontre un problème avec le format des dates que je récupère. À chaque fois, les dates sont dans un format différent, par exemple :

  • “23 11:30 2024 اغسطس”
  • “23 11:30 2024 مايو”
  • “26 11:30 2024 مايو”
  • “23 11:30 2024 يونيو”

Le mois peut changer à chaque fois et est parfois en arabe ou dans un autre format. Pourriez-vous me conseiller sur la meilleure manière de convertir ces dates en un format standardisé, tel que “DD/MM/YYYY”, de manière générale ?

Merci d’avance pour votre aide.
@samliew

Example

Screenshot_2024-08-27_000820

Result

Screenshot_2024-08-27_000835

Module Export - quick import into your scenario

You can copy and paste this module export into your scenario. This will import the modules (with fields/settings/filters) shown in my screenshots above.

  1. Move your mouse over the line of code below. Copy the JSON by clicking the copy button on the right of the code, which looks like this:

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the editor.

  3. Click on each imported module and re-save it for validation. There may be some errors prompting you to remap some variables and connections.

JSON module export — paste this directly in your scenario

{"subflows":[{"flow":[{"id":287,"module":"json:ParseJSON","version":1,"parameters":{"type":""},"mapper":{"json":"[\n  {\"date\": \"23 11:30 2024 اغسطس\"},\n  {\"date\": \"23 11:30 2024 مايو\"},\n  {\"date\": \"26 11:30 2024 مايو\"},\n  {\"date\": \"23 11:30 2024 يونيو\"}\n]"},"metadata":{"designer":{"x":2689,"y":-1395,"name":"Test Dates"},"restore":{"parameters":{"type":{"label":"Choose a data structure"}}},"parameters":[{"name":"type","type":"udt","label":"Data structure"}],"expect":[{"name":"json","type":"text","label":"JSON string","required":true}]}},{"id":286,"module":"groq:createJSONChatCompletion","version":1,"parameters":{"__IMTCONN__":2370769},"mapper":{"model":"llama-3.1-70b-versatile","systemPrompt":"You will receive possibly non-English dates, translate them, and extract them into JSON using the example format below.\n\nThe month and day should be two digits, padded with zero if it's a single digit.\n\nThe JSON should look like this:\n\n{\n  \"formatted_date\": \"31/12/2024\",\n  \"formatted_time\": \"11:59pm\",\n  \"military_time\": \"23:59\"\n}","userMessage":"{{287.date}}"},"metadata":{"designer":{"x":2936,"y":-1395,"name":"Translate and Format Date"},"restore":{"parameters":{"__IMTCONN__":{"label":"My Groq API Key connection","data":{"scoped":"true","connection":"groq"}}},"expect":{"model":{"mode":"chose","label":"llama-3.1-70b-versatile"}}},"parameters":[{"name":"__IMTCONN__","type":"account:groq","label":"Connection","required":true}],"expect":[{"name":"model","type":"select","label":"Model","required":true},{"name":"systemPrompt","type":"text","label":"System Prompt","required":true},{"name":"userMessage","type":"text","label":"User Message","required":true},{"name":"max_tokens","type":"number","label":"Max tokens returned"},{"name":"temperature","type":"number","label":"Temperature"},{"name":"top_p","type":"number","label":"Top P"},{"name":"frequency_penalty","type":"number","label":"Frequency Penalty"},{"name":"seed","type":"number","label":"Seed"}]}},{"id":288,"module":"util:TextAggregator","version":1,"parameters":{"rowSeparator":"","feeder":287},"mapper":{"value":"{{286.result.formatted_date}}{{newline}}"},"metadata":{"designer":{"x":3177,"y":-1394,"name":"Results","messages":[{"category":"last","severity":"warning","message":"A transformer should not be the last module in the route."}]},"restore":{"parameters":{"rowSeparator":{"label":"Empty"}},"extra":{"feeder":{"label":"Test Dates - Parse JSON [287]"}}},"parameters":[{"name":"rowSeparator","type":"select","label":"Row separator","validate":{"enum":["\n","\t","other"]}}],"expect":[{"name":"value","type":"text","label":"Text"}]}}]}],"metadata":{"version":1}}

Note: Did you know you can reduce the size of blueprints and module export code like the above, using the Make Blueprint Scrubber?

Hope this helps! Let me know if there are any further questions or issues.

@samliew


P.S.: Did you know, the concepts of about 70% of questions asked on this forum are already covered in the Make Academy. Investing some effort into it will save you lots of time and frustration using Make later!

“I would like to do the same thing, but in a general way so that it applies to all upcoming dates. How can I do this in that case?”

It should work, have you tried it yet? I provided proof for the four examples that you shown, that it is working.

If you need further assistance, please provide the following:

1. Relevant Screenshots

Please share screenshots of your scenario, any error messages, relevant module fields, and filters in question? It would really help other community members to see what you’re looking at.

You can upload images here using the Upload icon in the text editor:

2. Scenario Blueprint

Please export the scenario blueprint file to allow others to view the mapped variables in the module fields. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

3. Output Bundles of Modules

Please provide the output bundles of the modules by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.

A. Upload as Text File

Save each bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

B. Insert as Formatted Code Block

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles.
These are the two ways to format text so that it won’t be modified by the forum:

  • Method 1: Type code block manually

    Add three backticks ``` before and after the content/bundle, like this:

    ```
    content goes here
    ```

  • Method 2. Highlight and click the format button in the editor

Providing the input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

Yes, it worked, but I would like it to be general because I have multiple dates like that, and I want it to be applicable to all of them, but I don’t know how