I'm using SqlBulkCopy to save a read-only Excel sheet into a predefined SQL table.
There are several date columns in the sheet, but not all the rows have date values(empty and '#').
The corresponding columns types are varchar(20) and not smalldatetime, because otherwise I get an error that the data can not be converted.
After running SqlBulkCopy the dates are saved as numeric values in a pattern that I can't figure out.
31.12.2010 is saved as 40543
31.13.2011 is saved as 40908
30.6.2011 is saved as 40724
Now I have to present the date in web forms. The numeric values don't bother me as long as I can convert them back to date format for presenting in a GridView, but I don't know how.
Would appreciate any help with this.
I used the following:
where num is the numeric value of the date
Try running this query:
SELECT CAST(CAST(YourVarcharDateColumn AS int) AS DateTime) FROM YourTable