|
View previous topic :: View next topic
|
| Author |
Message |
Aneesh
New User
Joined: 30 Sep 2006 Posts: 60
|
|
|
|
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 |
|
 |
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
| 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 |
|
 |
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1056 Location: Richmond, Virginia
|
|
|
|
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 |
|
 |
Aneesh
New User
Joined: 30 Sep 2006 Posts: 60
|
|
|
|
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 |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
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 |
|
 |
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
| 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 |
|
 |
ruodeer
New User

Joined: 06 Jul 2007 Posts: 58 Location: home
|
|
|
|
| Code: |
SELECT CONCAT(CHAR(DATE(TIME_STAMP)),'-00.00.00.000000')
FROM TABLE |
|
|
| Back to top |
|
 |
|
|