How is your experience with the OutSystems Community?
46
Views
8
Comments
How to convert Data type from time to text
Question
Application Type
Reactive
  1. The input widget data is stored in a local variable, and its data type is TIME
  2. The database column data type is TEXT.
  3. I want to convert the Time value from HHMMSSformat to TEXT in HHMM format.



Test_DateType.oml
2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi,

Use FormatDateTime(LocalVariableName, "yyyyMMHHmmss")

Regards,

Daniel

2026-10-23 22-25-52
Edson Marques
 
MVP

Hi @Dilmi Amarasingha ,

The Date data type in OutSystems doesn't store time (HHMMSS). It only stores the calendar date. If your variable actually contains a time value, it is most likely a Time or DateTime, not a Date.

If it's a DateTime, you can use:

FormatDateTime(YourDateTime, "HHmm")

This returns a Text value such as 0930 or 1745.

If it's a Time value, you can first convert it to a DateTime (or use the appropriate formatting function available in your OutSystems version) and then format it using "HHmm".

If your variable is truly of type Date, there is no time component to extract, so you won't be able to produce an HHmm string from it. In that case, you should verify the data type of the input variable.

If anything comes up, please provide us with more information so we can help you.

UserImage.jpg
Dilmi Amarasingha

I want the input widget to allow users to enter only the time, without the date.

2025-11-18 12-43-07
Mariana Junges
Champion

If the goal is for the field to accept only a time value, bind the Input to a variable of type Time instead of DateTime.

When the Input is bound to a Time variable, OutSystems treats the value as a time and, on supported platforms, displays a time picker.

If your source value is a DateTime, use the following function: DateTimeToTime()

2024-03-12 10-44-32
Ram Kumar Baghel

Hi @Dilmi Amarasingha  

You can achieve this by using the FormatDateTime() function before saving the value to your Text attribute.

In the Assign node, use:

Source.StartTime = FormatDateTime(StartTime, "HHMM")

The FormatDateTime() function returns a Text value, so it can be stored directly in a Text attribute. Using the "HHMM" format will convert the Time value (HH:MM:SS) into the desired HHMM format (for example, 0930 or 1545).

I hope this helps!

TimetoText.oml
2025-04-10 11-25-12
Diogo Reis

Hi.

You can use FormatDateTime(TimeVar, HHmm).

2024-10-05 13-30-20
Huy Hoang The

Hi

Only use FormatDateTime to change format (FormatDateTime(TimeVar, HHmm)) and save it text field

2023-06-13 12-29-43
Sakthivel P

Hello @Dilmi Amarasingha,

Replace(FormatDateTime(LocalVariable_Time, "HH:mm"), ":", "")

How it works:

  • FormatDateTime(YourTimeLocalVar, "HH:mm"): OutSystems formats the Time variable into a standard string like "14:30".

  • Replace(..., ":", ""): Removes the colon (:), turning "14:30" into the 4-character string "1430".

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