Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Get current timestamp without using SQL query
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
mlp

New User


Joined: 23 Sep 2005
Posts: 91

PostPosted: Tue Dec 14, 2010 3:30 pm    Post subject: Get current timestamp without using SQL query
Reply with quote

I have a situation wherein I have to fetch the current timestamp without using SQL query. Now naturally quetion arises that why not use SQL query? This is because as per the architecture of the system we are not supposed to put SQL queries in the main module. But I have to get the timestamp in main module itself.

One way to do it, is to code a small program for fetching timestamp which will be called by main module.

But I want to know is there any other way which gives me the timestamp in main module itself?
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Dec 14, 2010 3:37 pm    Post subject:
Reply with quote

Timestamp of what
Back to top
View user's profile Send private message
mlp

New User


Joined: 23 Sep 2005
Posts: 91

PostPosted: Tue Dec 14, 2010 3:39 pm    Post subject:
Reply with quote

I need to get the current timestamp. The same is written in above post.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Dec 14, 2010 3:42 pm    Post subject:
Reply with quote

I am not a programmer but you say that you want a cuurent timestamp, and I asked a timestamp of what.

Do you mean the current system time, a timestamp of a table, a timestamp of something else, a timestamp on your clock card.

The help that you receive is directly related to the amount of useful information that you gives us.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Tue Dec 14, 2010 3:45 pm    Post subject:
Reply with quote

Expat,

this one is totally yours. Cause i like you. icon_wink.gif
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Dec 14, 2010 3:48 pm    Post subject:
Reply with quote

Peter,

No please, consider this as your Christmas gift icon_biggrin.gif
Back to top
View user's profile Send private message
mlp

New User


Joined: 23 Sep 2005
Posts: 91

PostPosted: Tue Dec 14, 2010 3:48 pm    Post subject:
Reply with quote

I need to get current system timestamp. And the resolution should be till microseconds. Becuase I need to get the microseconds from the timestamp for further processing.

I hope now it is more clear.... icon_smile.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Dec 14, 2010 3:53 pm    Post subject:
Reply with quote

if you want to derive/access a db2 CURRENT TIMESTAMP
(which is year, month, day, hour, min, sec, mill-sec)
for a COBOL (any programming language),
then an invocation of SQL from within the run-unit to return the CURRENT TIMESTAMP is what you need to do.


mlp wrote:
I need to get the current timestamp. The same is written in above post.

you want an answer to a very, very, very, simple, elemental problem,
and the fact that you even need to ask shows how little knowledge/skill you have.

that you answered expat's question in such a manner displays why you are asking a forum in the internet instead of a senior (or even beginner) at your site.

you are obviously oblivious to most everything around you, except yourself.
Back to top
View user's profile Send private message
mlp

New User


Joined: 23 Sep 2005
Posts: 91

PostPosted: Tue Dec 14, 2010 4:03 pm    Post subject:
Reply with quote

I dont want to question anybody's knowledge. I thought the current timestamp will be obivious. But I clarified the same in my successive post.

The reason I posted this topic is not to test any senior member's knowledge. I know the work-around and can implement my solution(as per my first post). But I really want to know that getting the current system timestamp "without using SQL query" is possible or not. I think it is a very honset question going in a very wrong direction.

If my post have sent you any wrong signals then my apologies for the same.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Tue Dec 14, 2010 4:08 pm    Post subject:
Reply with quote

Intrinsic fucntion CURRENT-DATE

Enterprise COBOL for z/OS Language Reference
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Tue Dec 14, 2010 4:37 pm    Post subject:
Reply with quote

Also, REXX's function TIME('L') will give you the same result.

O.
Back to top
View user's profile Send private message
mlp

New User


Joined: 23 Sep 2005
Posts: 91

PostPosted: Tue Dec 14, 2010 5:19 pm    Post subject:
Reply with quote

Hi Ofer, I think you really got my requirement.

But I need the time (in microseconds) in COBOL program.

Searched the COBOL manual but did not get anything which satisfies my requirement.

I think coding a program which gets the DB2 timestamp which is called by main module is the only way of getting the microseconds in the main module.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Tue Dec 14, 2010 5:20 pm    Post subject:
Reply with quote

Quote:
I thought the current timestamp will be obivious.
Terminology is critical in IT, where similar terms may mean very different things. "Timestamp" is a specific term, usually used in reference to databases, that refers to the date and time a particular record was added or updated in the data base. And do not blame others for your shortcoming in not being able to use the appropriate terminology -- it is YOUR responsibility to learn the terminology.

You are asking for the current system time (not timestamp), down to the millisecond. Find the Language Environment Programming Reference manual and read up on the CEE date functions -- you can get what you want from LE.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Dec 14, 2010 5:25 pm    Post subject:
Reply with quote

Also, the solution given by Ofer DOES go down to micro second level, so it is obvious that you DID NOT follow up on his suggestion.

You can execute TSO commands from a COBOL program, so you can use Ofer's suggestion, so stop being so negative and ask adult questions

Maybe something like ........................

Hi Ofer your suggestion gives me what I want, but can I do this from within a COBOL program and if so can you help me understand how.

Easy eh ?
Back to top
View user's profile Send private message
RahulChaudhari

New User


Joined: 03 Nov 2010
Posts: 11
Location: India

PostPosted: Tue Dec 14, 2010 5:33 pm    Post subject: Try this.
Reply with quote

Hi all,
simply writting accept <variable-name> from time will give u current timestamp in cobol.
hh:mm:ss:miliseconds please let me know if i am wrong.
thank you.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Dec 14, 2010 5:54 pm    Post subject:
Reply with quote

the accept from CURRENT DATE will return

yyyymmddhhmmssmm
not
yyyymmddhhmmssmmmmmm
the later being a 'timestamp' (without the '-', ':', and '.')

by the way, RahulChaudhari,
you are wrong.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Tue Dec 14, 2010 6:01 pm    Post subject:
Reply with quote

RahulChaudhari, not only do you use the wrong terminology ("timestamp" is not used in the COBOL Language Reference manual anywhere in talking about the ACCEPT verb), but you are also wrong about what is returned.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Dec 14, 2010 6:03 pm    Post subject: Reply to: Get current timestamp without using SQL query
Reply with quote

A small Assembler sub-program which is CALLED. It issues a STCK instruction, then uses the STCKCONV Macro to convert the STCK value to CCYYMMDDHHMMSSTHMIJU, with "MIJU" representing Milliseconds, Ten-Thousandths, Hundred-Thousandths and Microseconds, respectively.

Normally, this should not be used in CICS. But, check with your CICS Sysprog anyway as he/she might have a workaround.

Also, LE Callable routine CEELOCT will return the date/time as CCYYMMDDHHMMSSTHM, with the low-order "M" representing Milliseconds or the "THM" portion could be interpreted as Milliseconds.

Bill
Back to top
View user's profile Send private message
mlp

New User


Joined: 23 Sep 2005
Posts: 91

PostPosted: Wed Dec 15, 2010 10:17 am    Post subject:
Reply with quote

Now, we have two ways of getting the time.

1) With CEELOCT call which gives time till millisecond
2) With REXX function TIME('L') using TSO commands which gets time till last microsecond.

Now question is, which is best suited for the CICS env. I dont know for sure, but Can TSO commands be invoked from CICS env?
Back to top
View user's profile Send private message
RahulChaudhari

New User


Joined: 03 Nov 2010
Posts: 11
Location: India

PostPosted: Wed Dec 15, 2010 1:38 pm    Post subject:
Reply with quote

dbzTHEdinosauer wrote:
the accept from CURRENT DATE will return

yyyymmddhhmmssmm
not
yyyymmddhhmmssmmmmmm
the later being a 'timestamp' (without the '-', ':', and '.')

by the way, RahulChaudhari,
you are wrong.

Dear sir,
If i am not wrong ACCEPT <variable name> FROM DATE will give you current date in yymmdd format & not as you have written.ACCEPT <variable name> FROM TIME will give you output as hhmmssmm and REDEFINING this can give you desired output in any format like separator as / , - , : or any other separator you want.
Thank you.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm
No new posts SQL Query optimization. arunsoods DB2 12 Sun Sep 04, 2016 6:27 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us