none
Reading date from excel sheet and TryParseExact Fialed RRS feed

  • Question

  • Hello 

    I read date from excel sheet  Row("TransactionDate") this is the field from excel

     Dim TransactionDate As New Date

     Dim IsValidDate As Boolean = DateTime.TryParseExact(Row("TransactionDate"), "dd/MM/yyyy", Globalization.CultureInfo.InvariantCulture, DateTimeStyles.None, TransactionDate)

    i try to TryParseExact with the specified format which is "dd/MM/yyyy" but it returns null date 

    it works good on my PC but failed on my colleague PC , i checked the date format in tow PCs they are the same 

    what is the problem ?

    Monday, February 26, 2018 5:51 AM

All replies

  • Hello Nadia_BM,

    >>Row("TransactionDate") this is the field from excel

    What's the Row("TransactionDate")? What do you mean field from excel?

    I think  the Row("TransactionDate") result should be a string, right? 

    If you MsgBox its value before calling TryParseExact, what's its result string?

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 26, 2018 9:39 AM
  • Hi Nadia_BM,

    What is the value for "Row("TransactionDate")"?

    I suggest you make a test with code below on your colleague PC.

            Dim TransactionDate As New Date
            Dim IsValidDate As Boolean = DateTime.TryParseExact("28/01/2018", "dd/MM/yyyy", Globalization.CultureInfo.InvariantCulture, DateTimeStyles.None, TransactionDate)
    

    It would be helpful if you could share us your project with this Excel file.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 28, 2018 9:13 AM