Hello group, I start by saying that I’m using dates and that up to now I’ve been able to write my code without problems … now I’m having a problem with writing a function, where I pass the value of my date (I can decide whether to pass it as date or as string) from a textfield in the format dd/mm/YYYY.
MyDate = 01/12/2022 01=Day 12=month 2022=year
Function … (Quando as string)
Dim Year as integer
DIm Month as integer
Dim Day as integer
Dim PartiDellaData() as string=Split(Quando.ReplaceAll(" “,”“),”/")
Day=PartiDellaData(0).ToInteger
Month=PartiDellaData(1).ToInteger
Year=PartiDellaData(2).ToInteger
Markus makes mention of it, but it’s hard to catch. Date and DateTime are different classes. The framework being able to silently convert the classes for you is actually causing confusion here.
DateTime.FromString is not as flexible as the API 1 framework’s ParseDate function. You must provide the API 2 function a locale so that the function knows how to decipher nn/nn/nnnn.
You are declaring Temp_Quando as a Date, then using the DateTime function to parse the string. You can either revert to using the API 1 function ParseDate, or you can update your code to use DateTime. Since you have the individual values you should construct the object more specifically:
Thanks everyone for the info. Finally I used the “,LocalE.Current)” which converts the date to my format and then allows me to compare against the data in my database. Now everything works. Thank you.