FORMAT (column name); i.e.
SELECT FORMAT (date)
To change the display of a default output;
SELECT <column name> (format ‘pattern’)
For example to change the default output of the current date;
SELECT date (format ‘MMMDDYYYY’);
Other Symbols used for formatting (character) data;
X – Used for single representation of a character data.
9 – Used for single representation of an integer data (from 0-9 with “.” for decimal).
E- Used for Exponentials.
G- Used for single logical representation of a graphical data (images and languages).
Symbols used for special character formatting;
($ , . – / %) – Used for fixing any of the character of the similar nature, like $ for Dollar sign, “,” for Comma and “.” for decimal etc.
Symbols for DATE formatting
M – Used for Month display in case of date function. Single or double Ms are for digit display and three Ms (‘MMM’) are for character display of the month.
D – To display the day in a month in the date function.
Y – To display year in a date function. Note that a lower case of all the symbols above can also be used to get the same result. One example;
SELECT ‘MYFORMAT’ (FORMAT ‘XXxx’) as CharFormat,
4466466444 (FORMAT ’999-999-9999′) as PHONE,
13245.55 (FORMAT ’99999.999′) as DecimalFormat,
124445 (FORMAT ‘$$$,$$$$.99′) as DollarFormat
If you are using Teradata SQL Assistant, you might not see all the formatting displayed. USE BTEQ instead to see proper output.
Our Random Articles
- Somdev Devvarman ousts Xavier Malisse 6-1, 3-6,7-6(5)
- How To Choose A Good Online Traffic School
- New Year Wishes 2010
- New Year Wishes
- How to use EXTRACT function with date and time columns
More Links




4 Comments
Material that you are providing is very easy to learn. But it is much better than this , if you ll give the full material of this at ONE LINK.
Thank you
Suresh.
That is right Suresh. This is the reason I have given all the links in one page, please visit this
http://readvitamin.com/teradata/
Hope this helps.
Hi. Can anyone tell me how to extract time from timestamp?
For Example
timestamp=’2008-03-28 14:11:04′
i want time ’14:11:04′ from timestamp through query.
Thanks in advance.
Hi Vaideesh,
If you need only time, you can probably try the following;
SELECT time;
To answer your question you should do something like this.
SELECT CAST(VaideeshTime as time(0)) from timestamp;
VaideeshTime
——–
14:11:04
Hope that helps.