Home > Ask the AS/400 Experts > Questions & Answers > Working with date and timestamp in DB2
Ask The iSeries 400 Expert: Questions & Answers
EMAIL THIS

Working with date and timestamp in DB2

Kent Milligan EXPERT RESPONSE FROM: Kent Milligan

Pose a Question
Other iSeries 400 Categories
Meet all iSeries 400 Experts
Become an Expert for this site
>
QUESTION POSED ON: 26 February 2003
Is it possible to DB2/400 to automatically keep track of the timestamp when the record is inserted or updated? I created the following PF.

 
 FMT PF
.....A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++
*************** Beginning of data *************************************
0001.00      A          R PETEST

0002.00      A            PEER           3A

0003.00      A            PEEN          10A

0004.00      A            PTIM            T

0005.00      A            PDAT            L         DATFMT(*ISO)

0006.00      A            PTST            Z

****************** End of data ************************* 

When the record is written to the PF, timestamp, date and time are initialized as follows. I read the documentation, the time/date and timestamp information should be initialized with current date and time. When I've updated this record with SQL, timestamp is not updating with the current date and time. I wonder if this is even possible with DB2/400 to keep track of time stamp automatically (I mean with out pushing time stamp value by some program).

PEER: AAA
PEEN: AAA
PTIM: 00.00.00
PDAT: 0001-01-01
PTST: 0001-01-01-00.00.00.000000


>

If the ALWNULL & DFT keywords are left off of a Date or Timestamp field, then DB2 UDB for iSeries will assign the current date and time as the default value when a record is inserted. Updates to a record with a date or timestamp field does not change the value of these fields unless the Write or Update operation has explicitly changed the value of the date or timestamp field. The net is that DB2 UDB for iSeries can only automatically timestamp new records inserted into the database.

==================================
MORE INFORMATION ON THIS TOPIC
==================================

Search400.com's targeted search engine: Get relevant information on DB2/400.

The Best Web Links: tips, tutorials and more.

Check out this online event, Getting the Most out of SQL & DB2 UDB for the iSeries.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



iSeries Networking - Printing, Remote Access, TCP/IP
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts