If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Date/time

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-29-07, 22:37
samu78nyc samu78nyc is offline
Registered User
 
Join Date: Nov 2006
Posts: 31
Date/time

Hi all,
I have two columns OPEN_DATE (ex...2007-03-27) and OPEN_TIME (ex...15:20:54)
The time format I am required to display - mm/dd/yyyy hh:mm
I am using the below script

select ltrim(rtrim(char(month(open_date))))|| '/' ||ltrim(rtrim(char(day(open_date))))||'/'||ltrim(rtrim(char(year(open_date))))||' '||ltrim(rtrim(char(hour(open_time))))||':'||ltrim (rtrim(char(minute(open_time)))) from <table>

Result : 3/27/2007 15:20

The problem is how do I get the month as '03' instead of just '3'

Thanks in advance..
Reply With Quote
  #2 (permalink)  
Old 03-29-07, 23:09
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Instead of using month, day, year, etc functions, I would use the substr funciton of the date column for each of these.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 03-30-07, 00:59
rahul_s80 rahul_s80 is offline
Registered User
 
Join Date: Jul 2006
Location: Pune , India
Posts: 433
db2 values char(date ('2007-03-27'),usa)
1
----------
03/27/2007

and then concat the time
__________________
Rahul Singh
Certified DB2 9 DBA / Application Developer
Reply With Quote
  #4 (permalink)  
Old 03-30-07, 13:27
samu78nyc samu78nyc is offline
Registered User
 
Join Date: Nov 2006
Posts: 31
Thanks..

Great.....Thanks!!!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On