View previous topic :: :: View next topic
|
Author |
Message |
mlp
New User
Joined: 23 Sep 2005 Posts: 91
|
|
|
|
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 |
|
 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8657 Location: Back in jolly old England
|
|
|
|
Timestamp of what |
|
Back to top |
|
 |
mlp
New User
Joined: 23 Sep 2005 Posts: 91
|
|
|
|
I need to get the current timestamp. The same is written in above post. |
|
Back to top |
|
 |
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8657 Location: Back in jolly old England
|
|
|
|
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 |
|
 |
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2446 Location: Netherlands, Amstelveen
|
|
|
|
Expat,
this one is totally yours. Cause i like you.  |
|
Back to top |
|
 |
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8657 Location: Back in jolly old England
|
|
|
|
Peter,
No please, consider this as your Christmas gift  |
|
Back to top |
|
 |
mlp
New User
Joined: 23 Sep 2005 Posts: 91
|
|
|
|
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....  |
|
Back to top |
|
 |
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6970 Location: porcelain throne
|
|
|
|
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 |
|
 |
mlp
New User
Joined: 23 Sep 2005 Posts: 91
|
|
|
|
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 |
|
 |
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2446 Location: Netherlands, Amstelveen
|
|
|
|
Intrinsic fucntion CURRENT-DATE
Enterprise COBOL for z/OS Language Reference |
|
Back to top |
|
 |
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2360 Location: Israel
|
|
|
|
Also, REXX's function TIME('L') will give you the same result.
O. |
|
Back to top |
|
 |
mlp
New User
Joined: 23 Sep 2005 Posts: 91
|
|
|
|
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 |
|
 |
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8280 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
 |
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8657 Location: Back in jolly old England
|
|
|
|
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 |
|
 |
RahulChaudhari
New User
Joined: 03 Nov 2010 Posts: 11 Location: India
|
|
|
|
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 |
|
 |
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6970 Location: porcelain throne
|
|
|
|
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 |
|
 |
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8280 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
 |
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2504 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
 |
mlp
New User
Joined: 23 Sep 2005 Posts: 91
|
|
|
|
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 |
|
 |
RahulChaudhari
New User
Joined: 03 Nov 2010 Posts: 11 Location: India
|
|
|
|
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 |
|
 |
|