GM said:
i have datacolumn that formating dd/mm/yyyy hh/mm/ss. i try getting between from two date like
select * from X Where Date between 01.11.2008 11/12/33 and 30.11.2008 11/12/33. but it runs wrong.i can not displaY DIFFRENCE DATE
Are you storing the values as varchar in the database? A datetime value
doesn's have a format at all, it only gets a format when you format the
value into a string.
If you store the values as varchar, they are not in a format that is
comparable. The only comparable date format is the ISO 8601 format, i.e.
yyyy-mm-dd hh:mm:ss, as the components are always the same length, and
it places the most significant components first in the string. To
compare dates in any other format, you have to convert each value into a
datetime value before doing the comparison, which gets rather slow.
If you store the values as datetime, and see them formatted like you
described in a program that manages the database, e.g. Management
Studio, that only means that the program displays the dates that way,
not that the database itself will understand that date format. The best
way to send DateTime values to the database is to use parameters, as
jp2msft described.