472,146 Members | 1,415 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

convert excel date to asp date

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
3 2726
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
3,406 Expert 2GB
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
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.

Similar topics

3 posts views Thread by jerry.ranch | last post: by
2 posts views Thread by Franck | last post: by
4 posts views Thread by Daniel Kaseman | last post: by
1 post views Thread by simchajoy2000 | last post: by
17 posts views Thread by Terry Jolly | last post: by
2 posts views Thread by noopathan | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.