简体   繁体   中英

Convert Date Format

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM