473,513 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

yyyy from timestamp

Hi

Can anyone tell me how to derive "yyyy" from a timestamp column in
db2? Something like to_char(sysdate, 'yyyy') ... in oracle. I have to
oracle-like to_char function but its very slow.

If the column is DATE then I can use char(date, USA) and then substr
of 'yyyy', but I am not sure how can I do this with timestamp.

Please help

Thanks

V Prakash
Nov 12 '05 #1
4 5322
"Prakash" <ve***********@hotmail.com> wrote in message
news:78**************************@posting.google.c om...
Hi

Can anyone tell me how to derive "yyyy" from a timestamp column in
db2? Something like to_char(sysdate, 'yyyy') ... in oracle. I have to
oracle-like to_char function but its very slow.

If the column is DATE then I can use char(date, USA) and then substr
of 'yyyy', but I am not sure how can I do this with timestamp.

Please help

Thanks

V Prakash


You can download PDF versions of the manual here:
www-3.ibm.com/cgi-bin/db2www/data/db2/udb/winos2unix/support/v8pubs.d2w/en_m
ain

You want the SQL Reference.

Look at the YEAR function
Nov 12 '05 #2
Prakash wrote:
Hi

Can anyone tell me how to derive "yyyy" from a timestamp column in
db2? Something like to_char(sysdate, 'yyyy') ... in oracle. I have to
oracle-like to_char function but its very slow.

If the column is DATE then I can use char(date, USA) and then substr
of 'yyyy', but I am not sure how can I do this with timestamp.

Please help

Thanks

V Prakash


Hi V, you can use year function to do that. Something like year(sysdate)
will give a integer value of the year.

Nov 12 '05 #3
Thank you all.

V Prakash
Nov 12 '05 #4
Look at this: ( DB2 Basics: Fun with Dates and Times )
http://www-106.ibm.com/developerwork.../0211yip3.html
I guess it´s more than what you expect.

Cheers
Stefan

--
IT Consulting Stefan Krämer
D-88682 Salem
http://www.skc-group.com
Prakash schrieb:
Hi

Can anyone tell me how to derive "yyyy" from a timestamp column in
db2? Something like to_char(sysdate, 'yyyy') ... in oracle. I have to
oracle-like to_char function but its very slow.

If the column is DATE then I can use char(date, USA) and then substr
of 'yyyy', but I am not sure how can I do this with timestamp.

Please help

Thanks

V Prakash


Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
26339
by: MyOracle | last post by:
Hi everybody, I just curious about change date(0000-00-00) to date (00-00-0000) in mysql.Can anyone tell me about that. Thanks. izmanhaidi.
2
5173
by: rong.guo | last post by:
Hello Group, I am having a really weird problem... Can anyone tell the difference between Query 1 and Query 2 below? Why Query 2 excludes '2/28/2005'? Many thanks! create table a...
2
18371
by: gimme_this_gimme_that | last post by:
Assuming data is being stored in a DB2 TIMESTAMP what is the equivalent of Oracle's to_date function : to_date('03/04/2005','MM/DD/YYYY') It's OK if MM/DD/YYYY is the only supported format....
10
2174
by: OtisUsenet | last post by:
Hello, I am trying to select distinct dates and order them in the reverse chronological order. Although the column type is TIMESTAMP, in this case I want only YYYY, MM, and DD back. I am...
2
4331
by: Russell Smith | last post by:
Timestamps support infinity. However if appears dates do not. When timestamps are cast to dates, there is no output. Is this an acceptable option or not? Below are a number of examples...
22
6390
by: Mal Ball | last post by:
I hope I have the right forum for this question. I have an existing Windows application which uses a SQL Server database and stored procedures. I am now developing a web application to use the same...
7
6089
by: JJ | last post by:
How do I set one field to have the updated timestamp, and another to have the created timestamp? I want to do this directly from code generated from DB Designer if possible?! JJ
12
48162
by: Vincent Delporte | last post by:
Hello My site is hosted on a server in the US, hence set up to use the mm/dd/yyyy date format instead of the European dd/mm/yyyy. Also, MySQL stores dates as yyyy-mm-dd, so I need to convert...
3
52387
by: yogi | last post by:
Hi, I am working on a database that has a variable with timestamp values. I wanted to convert the variable from timestamp to yyyy-mm-dd format. Thanks in advance Yogi
0
7175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7391
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7553
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7120
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5697
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4754
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
466
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.