Hey everyone! 👋
If you're working with the low-code platform Uniface, you know that handling data correctly is super important. Today, we're going to look at one of the most basic building blocks: the date data type in Uniface 10.4.
Full disclosure: This post was created with the help of an AI to explain the official documentation in simple terms.
What Exactly is the date Data Type? 🤔
In Uniface, the date data type isn't just any date. It's a special data type that stores a date as a sequence of numbers in a very specific format: ccyymmdd.
- cc: Century
- yy: Year
- mm: Month
- dd: Day
So, for example, Christmas Day 2025 would be stored as the number 20251225. It's a simple, number-based representation without any dashes or slashes.
Show Me the Code! 💻
You'll most often use the date type when you define variables or parameters in your ProcScript code. The documentation mentions you can use it in params and variables blocks.
Here’s a simple example of how to declare a date variable in a component's script:
variables
date vMyDeadline
endvariables
vMyDeadline = 20260131 ; This sets the deadline to January 31, 2026
message "The project deadline is: %%vMyDeadline"
In this snippet, we created a variable named vMyDeadline and gave it the type date. Then, we assigned a value to it using the ccyymmdd format.
Working with Other Data? Use $date! ✨
What if your date is in a different format, like a string from a user input? That's where the built-in $date function comes in handy. You can use it to convert other data types into the proper Uniface date format.
Let's say you have a string. You can convert it like this:
variables
string vDateString
date vConvertedDate
endvariables
vDateString = "2025-11-15" ; A common string format
vConvertedDate = $date(vDateString) ; Convert the string to a Uniface date
; Now, vConvertedDate holds the value 20251115
message "The converted date is: %%vConvertedDate"
The $date function is smart enough to understand many common date formats and convert them for you. This is essential for making your application robust.
Key Takeaways 🚀
- The Uniface
datedata type stores dates in the numericccyymmddformat. - You declare date variables in the
variablesblock of your ProcScript. - Use the
$datefunction to convert strings or other data types into a proper Uniface date.
And that's a quick intro to the date data type! It’s a fundamental concept, but getting it right is key to building solid Uniface applications. Happy coding!
Top comments (0)