|
|
|
Forum 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
|
|
|
|
|
Supreme 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
|
|
|
|
|
Supreme 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.
|
|
|
|