Link to home
Start Free TrialLog in
Avatar of MichMat
MichMat

asked on

Convert a string to Excel serial date number

Hi,

In VB.net how do I convert a string "dd/mm/yyyy" into excel serial number as a string?
The date is going back into a CSV file so the output will be text anyway.

Thank you

Michal
Avatar of vs1784
vs1784

DateTime.ToString
Here is detailed article on that

http://articles.techrepublic.com.com/5100-3513-6106789.html

Hope it helps

Thanks
Avatar of MichMat

ASKER

Thank you, however that only addresses the string, the conversion to Excel serial number isnt there
unless Im missing something.

Michal
Convert it to date then to long and then to string.
--
JimFive
Try this

DateTime.ToOADate  - it returns double

Then convert double to string.
Avatar of MichMat

ASKER

That still does not give me the EXCEL SERIAL DATE NUMBER or does it ?
ASKER CERTIFIED SOLUTION
Avatar of vs1784
vs1784

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MichMat

ASKER

Thank you

Dim Adate as DateTime
Dim a_date_string as string = "13/08/2008" (AU format)

 ADate = CDate(a_date_string)
 a_date_string = ADate.ToOADate.ToString 'Date