Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to set date and time created in a db table

jrgkraus
Active Contributor
0 Kudos

When creating new DB tables in ERP, I want to add also columns to carry the time stamps for creation and last change.

SAP standard tables normally use a DATE and TIME field for that (ERDAT/ERZET). But since the DATE is relative to the time zone, I tend to using a TIMESTAMP field. What do you think? Do you use TIMESTAMP or DATE/TIME fields for this purpose?

1 ACCEPTED SOLUTION

pokrakam
Active Contributor

With my techie hat on I agree timestamp is more accurate and has certain benefits. But from a usability perspective I find them a pain to work with. How often do you want to find stuff that happened in a date range vs stuff that happened during a specific time interval? With dates you have the calendar dropdown in SE16 to tell you that the first week of this month was 20170807000000 - 20170813235959. So, give me date and time please.

Using sy-datum is universal and time-zone independent as it is the system date. So I would always use date and time, and if I have a specific need for a timestamp, I add this as an extra field. SAP seems to follow this, the only tables only with timestamps are low-level techie tables. Not many users are going to poke around ARFCSSTATE 🙂

3 REPLIES 3

pokrakam
Active Contributor

With my techie hat on I agree timestamp is more accurate and has certain benefits. But from a usability perspective I find them a pain to work with. How often do you want to find stuff that happened in a date range vs stuff that happened during a specific time interval? With dates you have the calendar dropdown in SE16 to tell you that the first week of this month was 20170807000000 - 20170813235959. So, give me date and time please.

Using sy-datum is universal and time-zone independent as it is the system date. So I would always use date and time, and if I have a specific need for a timestamp, I add this as an extra field. SAP seems to follow this, the only tables only with timestamps are low-level techie tables. Not many users are going to poke around ARFCSSTATE 🙂

0 Kudos

Hello,

I agree with Mike. I always use SY-DATUM and SY-UZEIT for DB entries and if I need a timestamp or a local Time display I use classes like that :

https://wiki.scn.sap.com/wiki/display/ABAP/Basic+date+calculations+using+class+-+CL_RECA_DATE

https://archive.sap.com/discussions/thread/869500

Former Member
0 Kudos

For this purpose I'd use DATE/TIME. At least, it seems more logical to me. Actually, i was using this for DB table and by far it's been working fine. You should use DATA/TIME.