IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Timestamp with time zeros


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Aneesh

New User


Joined: 30 Sep 2006
Posts: 60

PostPosted: Tue Nov 06, 2007 12:31 am
Reply with quote

Hi,

Is there any function that could be used to return the current timestamp with time as zeros.

2007-11-05-00.00.00.000000

Thanks in advance,
Aneesh
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Nov 06, 2007 1:21 am
Reply with quote

Aneesh wrote:
Hi,

Is there any function that could be used to return the current timestamp with time as zeros.

2007-11-05-00.00.00.000000

Thanks in advance,
Aneesh


1. A timestamp with a time of 0 wouldn't be the current timestamp.

2. What language are you using COBOL, ASM, etc?

3. Where are you trying to get it from, ZOS, CICS, DB2?
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1056
Location: Richmond, Virginia

PostPosted: Tue Nov 06, 2007 2:27 am
Reply with quote

Can you come up with nested functions that:

convert current timestamp to char, substr the left part you want, concatenate the zeroes you want, with appropriate delimiter chars, then convert the whole thing back to timestamp?
Back to top
View user's profile Send private message
Aneesh

New User


Joined: 30 Sep 2006
Posts: 60

PostPosted: Tue Nov 06, 2007 3:26 am
Reply with quote

Hi,

I apologize for the confusion. I am trying to do an unload from DB2 using an unload utility on mainframe ZOS. I have a particular scenario where i need the unload criteria based on created timestamp with the time zeroed out.

I can create the the field by concatenating the date with zeros to create the format - is there any function in DB2 that would allow this.

Thanks,
Aneesh.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Tue Nov 06, 2007 3:46 am
Reply with quote

Hello,

In a select, (IIRC) you can have the query return selected columns as well as literals.

You might try that. I've not tested this in db2 (i'm not yet connected<g>), but do seem to recall doing this in other "standard" sql.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Nov 06, 2007 3:56 am
Reply with quote

I think this might work, I don't have DB2 available right this minute but this should be right.
Code:
WHERE TIME_STAMP >= TIMESTAMP(CHAR(CURRENT DATE) CONCAT '-00.00.00.000000')
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10903
Location: italy

PostPosted: Tue Nov 06, 2007 4:10 am
Reply with quote

my db2 is quite rusty,

but what' s wrong in using the built in function DATE

WHERE DATE(TIME_STAMP) >= SELECT DATE(CURRENT TIMESTAMP) FROM SYSIBM.SYSDUMMY

or

WHERE DATE(TIME_STAMP) >= SELECT CURRENT DATE FROM SYSIBM.SYSDUMMY

cancel this post if I am blatantly wrooong
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Nov 06, 2007 4:52 am
Reply with quote

enrico-sorichetti wrote:
my db2 is quite rusty,

but what' s wrong in using the built in function DATE

WHERE DATE(TIME_STAMP) >= SELECT DATE(CURRENT TIMESTAMP) FROM SYSIBM.SYSDUMMY

or

WHERE DATE(TIME_STAMP) >= SELECT CURRENT DATE FROM SYSIBM.SYSDUMMY

cancel this post if I am blatantly wrooong


These are the correct format but, if the time_stamp column is indexed I think these will cause a table scan

Code:
WHERE DATE(TIME_STAMP) >= CURRENT DATE

or

WHERE DATE(TIME_STAMP) >= CURRENT DATE
Back to top
View user's profile Send private message
ruodeer

New User


Joined: 06 Jul 2007
Posts: 58
Location: home

PostPosted: Wed Nov 14, 2007 2:09 pm
Reply with quote

Code:
SELECT CONCAT(CHAR(DATE(TIME_STAMP)),'-00.00.00.000000')
FROM TABLE
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts PL/1 SEND CICS MAP first time, attrib... CICS 6
No new posts convert arbitrary UTC to local (SYD) ... COBOL Programming 1
No new posts Help with SORT - I need to validate d... DFSORT/ICETOOL 11
No new posts To get the count of rows for every 1 ... DB2 3
No new posts To get the the current time DFSORT/ICETOOL 13
Search our Forums:


Back to Top