简体   繁体   中英

How to convert Fuzzy date as Date field in SQL and VB.net

I have a duedate field on a table which the datatype is Fuzzydate. How to convert this to Date field in SQL and VB?

For example the Duedate on backend is : Duedate = 20160531 and I wan to convert it as Duedate = 2016-05-31

If this is always in the exact format you specified then you can use DateTime.ParseExact:

dateValue = DateTime.ParseExact("20160531", "yyyyMMdd", CultureInfo.InvariantCulture)

If it is in a number of different formats, you can use TryParseExact a number of times with different formats or just:

CDate()

Then to convert it to whatever date format you need:

dateValue.ToString("yyyy-MM-dd")

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