format date7time in vb.net

  • Thread starter Thread starter pp
  • Start date Start date
P

pp

I have this kind of format dates "02-01-2001 16:00" in a excel
spreadsheet (dd-mm-aaaa h:mm).

In vb.net I have this code:
Dim tempo As string
tempo=oExcelWs.Cells(i, 1).Value

and I get this date: tempo = "01-02-2001 16:00", the code have switched
the month whit the day.

Can anyone help me?
Thanks
Paulo Praça
 
Try this:

Dim tempo as String
tempo = Format(oExcelWS.Cells(i,1).Value, "dd-mm-yyyy h:mm")

Let me know if that works.

Mark
 
Mark said:
Try this:

Dim tempo as String
tempo = Format(oExcelWS.Cells(i,1).Value, "dd-mm-yyyy h:mm")

Let me know if that works.

Mark
Thanks Mark,
I solve my problem this way:


dim time as DateTime
Dim MyDateTime As String

MyDateTime = time.ToString("dd-MM-yyyy h:mm")

Paulo Praça
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top