Question : date format validation sybase stored procedure

we have business requirment that perform date format valitation at .NET side or sybase stored procedure ( application .NET calls the stored procedure)
only accept MON DD, YYYY format.

our server is Adative 12.5.4

create procedure aa
@hire_date datetime

as begin
.
.
.
insert into emplyee(hire_date,.....)
                 values(@hire_date,.....)
..
end

it works for all these input parameters:
                                                         DEC 25,2010
                                                         DEC 25,10
                                                         25 DEC,2010
                                                         12/25/2010
                                                         25/12/2010
                                                         dec 25,2010
but we don not want it accept 12/25/2010 or 25/12/2010, only DEC 25,2010 format.
in the sybase stored procedure , what can we do for this validation?

thanks

Answer : date format validation sybase stored procedure

You could try declaring the input parameter as

@hire_date varchar(20)

instead, and forcing it to a datetime in the SP

CONVERT(datetime, @hire_date, 107)

The SP will throw an error if an invalid format like 12/25/2010 is entered, which is also the same error that you would have received for a value like 13/13/2013 (invalid date) using the current SP.
Random Solutions  
 
programming4us programming4us