Sergey_New Well-Known Member Licensed User Longtime User May 31, 2025 #1 The application receives dates from an external source in the format "dd MMM yyyy". For example, "12 MAY 1920". When converting a date B4X: DateTime.DateFormat="dd MMM yyyy" Log(DateTime.DateTimeParse(DateTime.Date("12 MAY 1920"),"02:00:00")) an error occurs due to the fact that the month name must be "May". What can be done to make the process case-insensitive?
The application receives dates from an external source in the format "dd MMM yyyy". For example, "12 MAY 1920". When converting a date B4X: DateTime.DateFormat="dd MMM yyyy" Log(DateTime.DateTimeParse(DateTime.Date("12 MAY 1920"),"02:00:00")) an error occurs due to the fact that the month name must be "May". What can be done to make the process case-insensitive?
Solution stevel05 May 31, 2025 You need to change the Date/Time output Format to display both: B4X: DateTime.DateFormat="dd MMM yyyy" Dim L As Long = DateTime.DateTimeParse("12 MAY 1920","02:00:00") DateTime.DateFormat="dd MMM yyyy HH:mm:ss" Log(DateTime.Date(L))
You need to change the Date/Time output Format to display both: B4X: DateTime.DateFormat="dd MMM yyyy" Dim L As Long = DateTime.DateTimeParse("12 MAY 1920","02:00:00") DateTime.DateFormat="dd MMM yyyy HH:mm:ss" Log(DateTime.Date(L))
stevel05 Expert Licensed User Longtime User May 31, 2025 #2 Edit Explaination: The error is occurring because you are incorrectly parsing the date before passing it to DateTime.DateTimeParse. DateTime.DateTimeParse requires 2 Strings Try: B4X: DateTime.DateFormat="dd MMM yyyy" Dim L As Long = DateTime.DateTimeParse("12 MAY 1920","02:00:00") Log(DateTime.Date(L)) Log(DateTime.Time(L)) Upvote 0
Edit Explaination: The error is occurring because you are incorrectly parsing the date before passing it to DateTime.DateTimeParse. DateTime.DateTimeParse requires 2 Strings Try: B4X: DateTime.DateFormat="dd MMM yyyy" Dim L As Long = DateTime.DateTimeParse("12 MAY 1920","02:00:00") Log(DateTime.Date(L)) Log(DateTime.Time(L))
Sergey_New Well-Known Member Licensed User Longtime User May 31, 2025 #3 I need to get ticks from "12 MAY 1920" B4X: Dim L As Long = DateTime.DateTimeParse(DateTime.Date("12 MAY 1920"),"02:00:00") and not separately date and time Upvote 0
I need to get ticks from "12 MAY 1920" B4X: Dim L As Long = DateTime.DateTimeParse(DateTime.Date("12 MAY 1920"),"02:00:00") and not separately date and time
stevel05 Expert Licensed User Longtime User May 31, 2025 #4 You need to change the Date/Time output Format to display both: B4X: DateTime.DateFormat="dd MMM yyyy" Dim L As Long = DateTime.DateTimeParse("12 MAY 1920","02:00:00") DateTime.DateFormat="dd MMM yyyy HH:mm:ss" Log(DateTime.Date(L)) Upvote 0 Solution
You need to change the Date/Time output Format to display both: B4X: DateTime.DateFormat="dd MMM yyyy" Dim L As Long = DateTime.DateTimeParse("12 MAY 1920","02:00:00") DateTime.DateFormat="dd MMM yyyy HH:mm:ss" Log(DateTime.Date(L))
Sergey_New Well-Known Member Licensed User Longtime User May 31, 2025 #5 stevel05 said: Dim L As Long = DateTime.DateTimeParse("12 MAY 1920","02:00:00") Click to expand... Thank you, it works! Tell me if it is possible not to specify the time "02:00:00". I don't need it. Upvote 0
stevel05 said: Dim L As Long = DateTime.DateTimeParse("12 MAY 1920","02:00:00") Click to expand... Thank you, it works! Tell me if it is possible not to specify the time "02:00:00". I don't need it.
stevel05 Expert Licensed User Longtime User May 31, 2025 #6 Yes, just do: B4X: DateTime.DateFormat="dd MMM yyyy" Dim L As Long = DateTime.DateParse("12 MAY 1920") Log(DateTime.Date(L)) Upvote 0
Yes, just do: B4X: DateTime.DateFormat="dd MMM yyyy" Dim L As Long = DateTime.DateParse("12 MAY 1920") Log(DateTime.Date(L))
Sergey_New Well-Known Member Licensed User Longtime User May 31, 2025 #7 stevel05, thank you! Upvote 0