33
Views
2
Comments
Solved
Get Date from String
Question

HI,

My string "20250102" and wanted to convert it to OS Date #2025-01-02#

Thanks

2026-01-28 16-57-48
Mihai Melencu
Champion
Solution

Hello @Rohan J ,

To convert a string in the format "20250102" to an OutSystems Date value (#2025-01-02#), you can use the TextToDate() function with the proper string manipulation to match the expected format ("yyyy-MM-dd").


For your example:

TextToDate(Substr("20250102", 0, 4) + "-" + Substr("20250102", 4, 2) + "-" + Substr("20250102", 6, 2))


Explanation:

  • Substr("20250102", 0, 4) extracts the year "2025".
  • Substr("20250102", 4, 2) extracts the month "01".
  • Substr("20250102", 6, 2) extracts the day "02".
  • Concatenate them with "-": "2025-01-02".
  • TextToDate() converts the formatted string into a Date.
2024-12-18 16-06-42
Junaid Syed

Hello Rohan,

Here is a related post, you can find more options to achieve it.

https://www.outsystems.com/forums/discussion/87219/change-to-text-date-to-date-format/

Thanks,

Junaid

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.