views:

62

answers:

1

User updated in Excel as 01-03-2010 (as in DD-MM-YYYY). How do I covert this into YYYYMMDD in SQL? I have tried using FromDate=Format(Sheet1.Range("A3"),"yyyymmdd") and when I executed the SQL statement, it doesn't show any result.

A: 

If you are looking for dates on 20100301 then you usually need to filter like this

WHERE MyDate >= '20100301' AND MyDate < '20100302'

The column MyDate is likely to have a time component so if you use equals it fails. Or you can strip the time off the column but this would cause the db engine to not use an index, so it's better to do a range query as per my example.

BTW, yyyymmdd is the correct format.

gbn
Bob
@Bob: sorry, my yyyymmdd comment was to clarify what shekhar said (it's wrong). The date value also has to be in quotes too.
gbn