Thursday, March 8, 2012

date format problem

for example: when i use this statement
select [date] from order then the result are like that
12/12/2000 12:00 and there are time. It may be because i use thedatetime data type. but i only need 12/12/2000. i know it can change byusing CDate function in the program. But i only need to retrieve datefrom SQL Statement. How can i do that?

You can assign the results to a variable and then format it in the short date format:

Dim myDate as DateTime

myDate=(your value)
myDate=myDate.ToShortDateString

|||Or if you want to do it in the sql itself you can do something like :
SELECT
...
CONVERT(VARCHAR(10), datetimecolumn, 101)
FROM
<table>

No comments:

Post a Comment