Author Topic: Best way to query system log using UTC date?  (Read 943 times)

jsquizz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 576
    • View Profile
Best way to query system log using UTC date?
« on: November 30, 2021, 08:40:33 AM »
Hi Folks,

I am writing a simple script that captures some daily activity from the system log, using arsdoc query.

In dealing with the system log storing the date in UTC format so here's a quick snippet of my plan:

Code: [Select]
YESTERDAY=`something that generates yesterdays date`
2DAYSAGO=`somethinh that generates 2 days ago`

Now, throwing it into arsdoc query, my plan is this, example is - capturing 88 records for 11/29/21 Server Time-

Code: [Select]
"-i "where ODDAT_LOAD_DATE BETWEEN '$2DAYSAGO.16.59.59' and $YESTERDAY.16.59.59'"
Trying that approach and I am getting this error

Code: [Select]
DB Error: [IBM][CLI Driver][DB2/AIX64] SQL0180N  The syntax of the string representation of a datetime value is incorrect.  SQLSTATE=22007  -- SQLSTATE=22007, SQLCODE=-180, File=arsdoc.c, Line=3563
Does anyone have a handy way of getting things from the system log for the previous day, from a monitoring script, report, etc..?

Thanks!
#CMOD #DB2 #AFP2PDF #TSM #AIX #RHEL #AWS #AZURE #GCP #EVERYTHING

Justin Derrick

  • IBM Content Manager OnDemand Consultant
  • Administrator
  • Hero Member
  • *****
  • Posts: 2231
  • CMOD Guru for hire...
    • View Profile
    • Tenacious Consulting
Re: Best way to query system log using UTC date?
« Reply #1 on: December 02, 2021, 01:06:16 PM »
Make sure the date format you're sending to the SQL statement matches the date format that DB2 can easily recognize:  YYYY-MM-DD-HH.MM.SS.FFFFFF  (where FFFFFF is a six-digit fraction of a second).

You may want to investigate using SQL's built-in functions like current timestamp and days to create your

-JD.
IBM CMOD Professional Services: http://TenaciousConsulting.com
Call:  +1-866-533-7742  or  eMail:  jd@justinderrick.com
IBM CMOD Wiki:  https://CMOD.wiki/
FREE IBM CMOD Education & Webinars:  https://CMOD.Training/

Interests: #AIX #Linux #Multiplatforms #DB2 #TSM #SP #Performance #Security #Audits #Customizing #Availability #HA #DR