Stoker, Kenneth E
Kenneth.Stoker at pnl.gov
Fri Apr 25 11:25:36 CDT 2003
These functions aren't too bad. Here is what I came up with. Most of you probably could have done this in your sleep. CREATE FUNCTION [dbo].whichMonth (@Month int) RETURNS varchar(3) AS BEGIN declare @Return varchar(3) select @return = case @Month when 1 then 'JAN' when 2 then 'FEB' when 3 then 'MAR' when 4 then 'APR' when 5 then 'MAY' when 6 then 'JUN' when 7 then 'JUL' when 8 then 'AUG' when 9 then 'SEP' when 10 then 'OCT' when 11 then 'NOV' when 12 then 'DEC' else 'Invalid' END return @return end Ken Stoker Technology Commercialization Information Systems Administrator PH: (509) 375-3758 FAX: (509) 375-6731 E-mail: Kenneth.Stoker at pnl.gov <mailto:Kenneth.Stoker at pnl.gov> -----Original Message----- From: Stoker, Kenneth E Sent: Friday, April 25, 2003 9:17 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer]Convert int month to char month Okay, I was afraid of that. I will try creating my first user-defined function. Any advise on these? Thank you. Ken Stoker Technology Commercialization Information Systems Administrator PH: (509) 375-3758 FAX: (509) 375-6731 E-mail: Kenneth.Stoker at pnl.gov <mailto:Kenneth.Stoker at pnl.gov> -----Original Message----- From: Mike and Doris Manning [mailto:mikedorism at ntelos.net] Sent: Friday, April 25, 2003 8:43 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer]Convert int month to char month SQL doesn't have anything built-in to do this so you will have to build your own user-defined function to handle it. Doris Manning Database Administrator Hargrove Inc. www.hargroveinc.com -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Stoker, Kenneth E Sent: Friday, April 25, 2003 11:27 AM To: dba-SQLServer (E-mail) Subject: [dba-SQLServer]Convert int month to char month Does anyone know of a way to convert the return value of month([mydate]) from an integer to its equivalent char value? 1 JAN 2 FEB 3 MAR ..... Thank you for your help. Ken Stoker Technology Commercialization Information Systems Administrator PH: (509) 375-3758 FAX: (509) 375-6731 E-mail: Kenneth.Stoker at pnl.gov _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com