cancel
Showing results for 
Search instead for 
Did you mean: 

How to derive Month from Date in IDT

former_member374954
Participant
0 Kudos

Hello Gururs,

I need to Create a predefine condition in Information Design Tool to see Month value from date value.

Can anyone please help?

Regards

P.Mangal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Just to be clear, do you mean display the year/month from a given date?

So for today you'd want to see something like 2014-07?

The main function that you will need is EXTRACT, e.g. EXTRACT(Month from table.column)

Alternatively you could cast but it is a bit more complex:

cast ((cast(table.column as format 'mmm')) as char(3)

Regards,

Mark

Answers (1)

Answers (1)

former_member4998
Active Contributor
0 Kudos

Hi


Find the below sample code

If your Db is SQl

select

DATE_ID as DATE_ID,

'Current month' as Periods

from td_Date

where

CalendarDate between DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)and DATEADD(ms,- 3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE())+1,0)))

union all


or SELECT CAST(MONTH(SYSDATETIME()) AS VARCHAR(2)) as [M]

If your database is BW...try to implement at the bex query level.

former_member374954
Participant
0 Kudos

Its Teradata.

former_member4998
Active Contributor
0 Kudos

Hi .. Is your problem had solve?

PLEASE change the question is Answered and blog as helpful & answered.