convert string to date format
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


convert string to date format Expand / Collapse
Author
Message
Posted 7/31/2008 10:30:04 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 7/31/2008 11:36:47 PM
Posts: 2, Visits: 5
Hi
How to convert the below date in string to date format.. I try the cast function but it does not
work...

July 22, 2007

Thanks,
Mohan
Post #12408
Posted 7/31/2008 11:09:39 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Yesterday @ 7:30:07 AM
Posts: 197, Visits: 611
Hello,

For character dates, you need to specify the format as well.

Examples:

SELECT CAST('July 22, 2008' AS DATE FORMAT 'MMMMBDD,BYYYY');

SELECT CAST ('January 1992' AS DATE FORMAT 'MMMMBYYYY');

Please note, the output format of the date (if using SQL Assistant) will be same as that of OS (in my case it is 07/22/2008 and 01/01/1992), though in BTEQ it will be formated with respect to the format string specified ('July 22, 2008' and 'January 1992').

Regards,

Adeel
Post #12410
Posted 7/31/2008 11:18:57 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: PAC and SFT Members
Last Login: Yesterday @ 6:11:07 PM
Posts: 331, Visits: 533
Select cast('July 22, 2007' as date format 'M4BDD,BY4');

Note that 'July 4, 2007' would NOT be valid with this format, though 'July 04, 2007' would be. Teradata does not have any format specifier that allows for a single-digit day of month.
Post #12411
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 1 ( 1 guest, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 12:17am

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.375. 8 queries. Compression Disabled.