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?
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?
%Date is just handling +$h, no time (that would be %Time)
%Timestamp is the real object equivalent of $h
Thank you, Robert!
So, if I want to put $H to a %Date property I do:
for %TimeStamp property to set current date/time, I do what?
Thanks, Vitaly! That's interesting!
in technology space it's nice and compatible to the UNIX/LINUX world
in the commercial arena it is just an alien
This datatype is not present in (currently latest) Caché 2017.2; it appears to be IRIS-only. That rather limits its usefullness. Besides, what is the performance of a datatype, and where is that a bottleneck?
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.
%PosixTime
set s.TimeStamp=$zdt($H,3)
it is already in ODBC format.
When working with $zd* functions It's better to specify what you need explicitly, because otherwise locale change can be an unwelcome surprise:
that's default anyhow
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.
Time in Posix is the time as %Integer counting from Jan 1st, 1970. A UNIX definition.
)
dates before are negative integers (e.g. birthdate before 1970
[that was a reason to start $h with Jan 1st, 1840. The year the oldest veteran (in 1960) from civil war at MGH was born ]
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue