For developers working with the Uniface low-code platform, precise data handling is paramount. Among the fundamental data types, the date type in Uniface 10.4 plays a crucial role. This guide will demystify its structure and usage, ensuring you can confidently manage dates within your applications.
Understanding the Uniface date Data Type
In Uniface, the date data type is distinct. It stores date values as a sequential series of numbers, adhering to a strict ccyymmdd format:
- cc: Represents the Century
- yy: Denotes the Year
- mm: Indicates the Month
- dd: Specifies the Day
For instance, a date like December 25th, 2025, would be internally represented as the numeric value 20251225. This format is purely numerical, devoid of any separators like hyphens or slashes, making it efficient for storage and comparison within the Uniface environment.
Declaring and Using Date Variables in ProcScript
You’ll primarily encounter the date data type when defining variables or parameters within your ProcScript code. The Uniface documentation highlights its use within params and variables blocks. Here’s a practical illustration of declaring and initializing a date variable:
variables
date vProjectDeadline ; Declare a variable named vProjectDeadline of type date
endvariables
vProjectDeadline = 20260131 ; Assign the date January 31, 2026, using the ccyymmdd format
message "Your project deadline is: %%vProjectDeadline" ; Display the assigned date
In this example, we first establish vProjectDeadline as a date type. Subsequently, we assign it a specific date value using the mandated ccyymmdd numeric string.
Converting Data to the Uniface date Type with $date
Often, date information might arrive in varying formats, such as a string input from a user interface. To convert these external formats into the native Uniface date type, you leverage the powerful built-in function, $date. This function is indispensable for robust application development, as it intelligently parses and converts diverse date strings.
Consider the following scenario where you need to convert a common string-formatted date:
variables
string vInputDateString ; A variable to hold the date as a string
date vConvertedUnifaceDate ; A variable to hold the converted Uniface date
endvariables
vInputDateString = "2025-11-15" ; Example: A date string from user input
vConvertedUnifaceDate = $date(vInputDateString) ; Utilize $date to convert the string
; After this operation, vConvertedUnifaceDate will contain the numeric value 20251115
message "The processed date is: %%vConvertedUnifaceDate" ; Display the converted date
The $date function significantly simplifies the process of integrating external date formats, making your Uniface applications more flexible and user-friendly.
Key Takeaways for Uniface Date Management
To summarize the essentials of working with the Uniface date data type:
- The Uniface
datedata type stores dates exclusively in the numericccyymmddformat. - Date variables are declared within the
variablesorparamsblocks of your ProcScript. - The
$datefunction is your go-to tool for converting strings or other data types into the correct Unifacedateformat.
Mastering the date data type is fundamental to building reliable and efficient Uniface applications. By understanding its structure and utilizing the $date function effectively, you can ensure accurate date handling throughout your projects. Happy coding!