ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   format date7time in vb.net (https://www.excelbanter.com/excel-programming/325177-format-date7time-vbulletin-net.html)

pp

format date7time in vb.net
 
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

Mark Bigelow

format date7time in vb.net
 
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


pp

format date7time in vb.net
 
Mark Bigelow wrote:
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


All times are GMT +1. The time now is 05:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com