COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: Kalyan cognoise on 20 May 2009 05:40:06 AM

Title: Extract Date from datetime column
Post by: Kalyan cognoise on 20 May 2009 05:40:06 AM
Can you please tell me how to extract date from datetime? Example Currently from database date is coming  like this-- Jan 3 2002 9:12:34:566AM and i want to extract date part from that. Date should be like  Jan 03, 2002.Actually I want to use this in value prompt not at report level.
Title: Re: Extract Date from datetime column
Post by: Gopinath on 20 May 2009 06:08:22 AM
use

cast([datetime field];Date)

Title: Re: Extract Date from datetime column
Post by: Kalyan cognoise on 20 May 2009 06:11:15 AM
Hi Gopinath,

I have already tried this. It is giving me m/d/yyyy not Mon/dd/yyyy

Kalyan
Title: Re: Extract Date from datetime column
Post by: ajaju on 20 May 2009 06:35:18 AM
Hi,

Try using date(DateTime field) function.
It will give you result in Mon dd,yyyy format.
HTH!

Title: Re: Extract Date from datetime column
Post by: Gopinath on 20 May 2009 07:40:01 AM
try using

to_date()
or
to_char()

functions.
Title: Re: Extract Date from datetime column
Post by: Gollapudi on 25 May 2009 03:42:12 AM
HI,

First of all I would like to mention one thing i.e. we use CAST function to Covert the DATA TYPE not the date... You can use extract(datepart, Datetime_exp)
and coming to to_date() or to_char() functions, If the data base is Oracle then only you can use to_date() or to_char() functions, otherwise you will have to do this in Cognos Report Studio Level by using Vendor specific Functions [if avaialable] or Cognos Functions like extract

Gollapudi.