ChangeTimestamptoyear
Moderators: chulett, rschirm, roy
ChangeTimestamptoyear
hi all,
I Want to convert my timestamp to month and year in separate columns. From which function i have to extract
thanks
I Want to convert my timestamp to month and year in separate columns. From which function i have to extract
thanks
What format is your timestamp in?
Take a look at the ICONV/OCONV functions.
If your date part of timestamp is alway YYYY-MM-DD
then for year you can do
for month you can do
Take a look at the ICONV/OCONV functions.
If your date part of timestamp is alway YYYY-MM-DD
then for year you can do
Code: Select all
LEFT(in.timestamp,4)
Code: Select all
OCONV(ICONV(LEFT(in.timestamp,10),"D-YMD[4,2,2]"),"DM")
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
HI SDguru2B
MY DATE format is in YYYY-MM-DD
I got the month ,how to get the year part like the one u provided for month
thks in advance
I got the month ,how to get the year part like the one u provided for month
thks in advance
DSguru2B wrote:What format is your timestamp in?
Take a look at the ICONV/OCONV functions.
If your date part of timestamp is alway YYYY-MM-DD
then for year you can dofor month you can doCode: Select all
LEFT(in.timestamp,4)
Code: Select all
OCONV(ICONV(LEFT(in.timestamp,10),"D-YMD[4,2,2]"),"DM")
Pay attention to Craig's suggestion. That will be much faster.
As far as getting the year from ICONV/OCONV, use
As far as getting the year from ICONV/OCONV, use
Code: Select all
OCONV(ICONV(LEFT(in.timestamp,10),"D-YMD[4,2,2]"),"DY")
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
-
- Premium Member
- Posts: 209
- Joined: Fri Jan 09, 2004 1:14 pm
- Location: Toronto, Canada
- Contact:
Re: HI SDguru2B
Kumar,
Assuming format YYYY-MM-DD, Craig's suggestion breaks down to
Year = in.timestamp [1, 4]
Month = in.timestamp [6, 2]
Are you looking for more than that?
Rob
Assuming format YYYY-MM-DD, Craig's suggestion breaks down to
Year = in.timestamp [1, 4]
Month = in.timestamp [6, 2]
Are you looking for more than that?
Rob
Rob Wierdsma
Toronto, Canada
bartonbishop.com
Toronto, Canada
bartonbishop.com
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
If month might be one or two digits, the Field() function is more appropriate.
Adapt as required for different delimiter character.
Code: Select all
Field(in.Timestamp, "-", 2, 1)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.