We have a table that other fields also included the date, but it turns out that we have declared a data type "DateTime" and that by default when creating or editing the registry, this field also includes the time , minutes, seconds and milliseconds (08/06/2007 12:23:56.234) which was updated.
This can be a headache when performing a search in which we as a criterion for selecting the date field, and usually parameterize filter or different format and date: Select * from WHERE date purchases = '08 / 06/2007 '. And the result would be: Damn, I have no records.
Well I bring you a simple solution by means of a function made in SQL Server where you can filtrais no more trouble than run:
CREATE FUNCTION [dbo] . [CONVERT_FECHA_SIMPLE]
(
@ DATE DATETIME
)
RETURNS SMALLDATETIME
RETURN CAST ( CONVERT (varchar , @ DATE, 103 ) AS DATETIME )
END
Well, after this code, here deberais only thing you do in your stored procedure which will make the long-awaited consultation is call the function from the field convert_fecha_simple criterion, so, you look:
Shopping Select * from dbo.convert_fecha_simple WHERE (date) = '08 / 06/2007 '
0 comments:
Post a Comment