Reading custom time format from excel in C #

I am trying to read a non-regular time format from excel in C #, the time value in excel is “29-Aug-01 11.23.00.000000000 PM”, and in Excel the cell format is “regular” not “time”.

Now I need to read the time in excel and then assign the time in the calendar time in asp.net/c#, how can I let the program understand the time format?

Thank you very much!

my code is not working

DateTime expTime = DateTime.ParseExact(strDate, "dd-MMM-yy hh.mm.ss.fffffffff tt",      System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat);
+4
source share
2 answers

I have a similar solution, but more accurately.

string s = "29-Aug-01 11.23.00.000000000 AM";

DateTimeOffset myDate = DateTimeOffset.ParseExact(
    s,
    "dd-MMM-yy hh.mm.ss.fffffff00 tt",
    System.Globalization.CultureInfo.InvariantCulture);

EDIT: You cannot use more than 7 characters.

+1
source

, DateTime . :

var expTime = DateTime.ParseExact(strDate, "dd-MMM-yy hh.mm.ss.fffffff00 tt", 
              CultureInfo.InvariantCulture);

, 00 .

, CultureInfo.InvariantCulture UI Culture. , , . DateTime.ParseExact ,

0

Source: https://habr.com/ru/post/1528132/


All Articles