By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,230 Members | 2,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,230 IT Pros & Developers. It's quick & easy.

convert excel date to asp date

P: 20
Please help me to convert excel date to asp date.

Here is my code


objConnEx.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Netroot\WebApp\testprograms\Shuttle_Serv ice\Attachment\BusRequest.xls;Extended Properties=Excel 8.0;HDR=Yes;IMEX=1;"
set objRS = server.createObject("ADODB.recordset")
SQL = "SELECT * from [BusRequest$]"
objRS.Open SQL,objConnEx, 1

Do until objRS.eof

Response.write(objRS.fields(0).Value)
// The value of this in excel is 06/29/2007


objRS.Movenext
Loop

The output of this script is
39336
How Can I convert 39336 to 6/29/2007?

Thanks


THanks
Jul 3 '07 #1
Share this Question
Share on Google+
3 Replies


P: 11
Hi,
You could probably try the FromOADate() function. The only thing was when I tried it with the value you supplied I was off by 74 days so I subtracted that. Not sure if it would be affected by leap years though.


Expand|Select|Wrap|Line Numbers
  1.  
  2.         Dim myDate As DateTime
  3.  
  4. myDate = DateTime.FromOADate(39336 - 74)
  5.  
  6. Response.Write(myDate.ToString)
The 39336 would be replaced with a variable. Hope this helps.
Jul 3 '07 #2

jhardman
Expert 2.5K+
P: 3,405
Hi,
You could probably try the FromOADate() function. The only thing was when I tried it with the value you supplied I was off by 74 days so I subtracted that. Not sure if it would be affected by leap years though.
I tried it in excel and I also got 9/11/07

Jared
Jul 3 '07 #3

P: 11
I tried it in excel and I also got 9/11/07

Jared
I don't know then, I created a new website and tried that and it worked.

Forgive me for asking, but did you subtract the 74?
Jul 3 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.