All Forums Database
04 Jan 2008
Extracting month from date as 'MMM'

How can i extract month from a date in the MMM format.example 01-31-2008 I need to get an output 'JAN'can we do this with out using case statement?Thanks

Jim Chapman 449 posts Joined 09/04
04 Jan 2008

select current_date (format 'MMM'); *** Query completed. One row found. One column returned. *** Total elapsed time was 1 second.Date---- Jan

04 Jan 2008

jim,i tried it and i was still getting the date 01/04/2007has it got anything to do with the database settings or the teradata versionwe are currently using v2r5 and i issues this sql on queryman.Thanks

Jim Chapman 449 posts Joined 09/04
07 Jan 2008

My previous suggestion only works in BTEQ. Normally, output formatting is controlled by the client program, but you can use the CAST operator to force the Teradata server do the conversion.For example:sel cast ((cast(current_date as format 'mmm')) as char(3));

07 Jan 2008

Thank you very much JIM.

Luckyhansh 30 posts Joined 08/06
09 Jan 2008

Yes,Bteq and SQL assistant may have different result of the same sql,Just because bteq use CLI and SQL Assistant use odbc, but if you use sql for etl, you'd better try sqls in bteq

mur007 1 post Joined 02/14
2 weeks ago

In SQL Assistant we can use: 
SELECT Current_Date(FORMAT 'MMM') (CHAR(3)) AS MonthName

frnewbrough 41 posts Joined 03/08
2 weeks ago

This is also available. 
SELECT TO_CHAR(CURRENT_DATE, 'Mon');

You must sign in to leave a comment.