4D Blog

Home Product Dates inside objects!

Dates inside objects!

January 23, 2018

Product

Objects are great! Their flexibility, combined with speed and elegance, make them a first choice for most developers. Using dates inside objects is now easier and more intuitive. From now on, dates can be set as dates – and not strings inside objects!

How does it work?

In order to use dates inside objects, just check the compatibility setting, “Use date type instead of ISO date format in objects”, in the Database Settings.

Once this is done, OB SET and OB Get work without requiring the is date constant.

OB SET ($myObject;"myDate";$date)
$date:=OB Get ($myObject;"myDate")

Object Notation also works! Take a look:

$myObject.myDate:=$date
$date:=$myObject.myDate

Stringify and Parse

Compatibility is maintained

Prior to 4D v16 R6, when calling the JSON Stringify command, objects containing dates were systematically “stringified” according to the ISO 8601 normalization in the following format “YYYY-MM-DDThhmmss.sssZ” . The reverse operation, JSON Parse, did not interpret this format by default, and therefore produced a string.

What’s new?

If the compatibility option in the Database Settings is checked, dates will simply be formatted as “YYYY-MM-DD” (still following the ISO 8601 standard) when calling the JSON stringify command. When using JSON Parse, this string will then be set as a date (and not as a string) inside the object!

Change mode dynamically

If needed, this default setting can be changed by programming with the SET DATABASE PARAMETER command and the Dates inside object selector.

Reminder: SET DATABASE PARAMETER(Dates inside object;option) is local to the current process.

The three possible values for this option are now:

  • String type without time zone  (previously known as ignore local time zone)
  • String type with time zone  (previously known as take time zone into account)
  • Date type (new!)

As a result, when you import JSON data into 4D, you now have a way to dynamically change the format for dates.

Discuss

Tags Database, Objects, Programming, v16 R6, v17

Latest related posts

  • June 16, 2025

    Generate, share and use web sessions One-Time Passcodes (OTP)

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

Roland Lannuzel
Roland Lannuzel
• Product Owner & 4D Expert •After studying electronics, Roland went into industrial IT as a developer and consultant, building solutions for customers with a variety of databases and technologies. In the late 80’s he fell in love with 4D and has used it in writing business applications that include accounting, billing and email systems.Eventually joining the company in 1997, Roland’s valuable contributions include designing specifications, testing tools, demos as well as training and speaking to the 4D community at many conferences. He continues to actively shape the future of 4D by defining new features and database development tools.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy