Question
· Apr 13, 2018

Datatypes For Handling Date and Time in Persistent Classes

Hi, Community!

When I introduce a field to a persistent class to manage date/time what datatype should I prefer? 

%Date or %TimeStamp? And why?

Discussion (12)2
Log in or sign up to continue

Hi Robert,

Why did you say that the %TimeStamp datatype is the equivalent of the full $h? It's true that %Date/%Time do the conversion from internal date/time values to/from external. But %TimeStamp, %DateTime, and %StringTimeStamp  do not do any internal/external conversion. It's just for the YYYY-MM-DD HH:MM:SS external timestamp. Is there something I'm missing?

%PosixTimeStamp does convert, but it's not $h internally.

Other locales could have TimeFormat property not equal to 1, there are also custom locales.

I completely agree that in a wide range of scenarios defaults work fine, or rather defaults are what we expect them to be. However, that is not always the case, so I prefer (and advice) to use macros for $zd* functions with all relevant parameters specified.