48
Views
5
Comments
How to check if a variable with Time data type if empty or null ?
Question
Application Type
Reactive
Service Studio Version
11.55.13 (Build 64030)

How to check if a variable with Time data type if empty or null ? I tried VarTime = "" and TimeToText(VarTime ) = "" but it's no good.

2025-11-11 13-17-51
Rajan C

Hi @CoffeeCode ,

       Unfortunately there is no built in action to check the empty time but you can validate the time as shown below, 



2023-07-13 03-30-10
Ronaldd

But what if the user selects 12am in 24 hr format ?

2025-11-11 13-17-51
Rajan C

If user is selecting the time from date widget or time widget then there should be difference in the seconds so above approach will work.

Approach 2:

Instead of directly using the time datatype variable in the screen I suggest you to use text datatype variable and then convert the text value to time.

Please use the below link to test it

Test Link

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

Hi @CoffeeCode ,

One way to check if the time is null is by using the following condition, using DateTimeToDate to convert NullDate allows the time comparison to work properly. 

VarTime = DateTimeToTime(NullDate())

For your use case regarding 12 AM in the 24-hour format, OutSystems does not support an explicit "null" value for Time data types. Instead, unassigned time values default to 00:00:00. 

To determine whether the user has actually selected a time, consider implementing a Boolean variable (IsTimeSet):

  • Set IsTimeSet to True when the user selects a time.
  • Keep IsTimeSet as False if the user has never interacted with the time input.
2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi @CoffeeCode ,

just offering an alternative to everything else here.

Make both on server and client side a function called NullTime, with as output a time attribute.  No code needed in the function, the default value of the output is what you are after.

Then, you can just make expressions like this

which I think is 

  • highly readable
  • in sync with how it looks for the built-in NullDate()
  • avoids having to type the awkward literal with ## every time

Dorine

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