Hello, I have a string representation of the date - "01.02.2016", and I need to cast it to datetime with specific pattern "dd.MM.yyyy" to prevent wrong casting in another culture settings (e.g. en-us which will interpret it by pattern "MM.dd.yyyy").
How can I do this?
Thanks a lot!
2 Answers, 1 is accepted
answered on 01 Apr 2019, 03:37 PM
There is no a built-in way of providing the format when parsing a date. The recommended solution would be to create a User Function that accepts the string as argument and returns a DateTime instance according to the specified pattern. Another option is to convert the string to Date using the Date(year, month, day) function. The arguments can be provided using the Substr() function and each substring must be converted to an integer with CInt() to satisfy the Date() function requirements. In this case the expression would look like this:
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Telerik Feedback Portal
and vote to affect the priority of the items