Announcements
hi,
im trying to convert string to date. i am extracting a date value from a form using ActiveDate.valueStr() and storing this into a string var. i have put this into a container, converted the container into a string using con2str() and attached it to args, args.parm(strcon). i am passing this through an action menu item, and when i receive the value there through the same args.parm(), i am converting the string back to container and using conpeek() to extract the value. i am storing the extracted value back into a string. now i have created an edt called activeDate which is of type date and creating an instance of that and using str2date(str,123) i am trying to store it back into the activeDate instance but its showing the default value of 1/1/1900. on debugging its only at this statement where its not converting it.
thank you. it worked.
You've certainly added some complexity there that probably has nothing to do with your str2date(..) problem. Since you've already indicated that the date string obtained from ActiveDate.valueStr() survives "as is" all the way to str2Date, the problem must be there.
The 2nd parameter you provided to str2Date(.., 123) indicates that the date format is day, month, year. Is that the format returned by .valueStr() in your case? It may (I have not tested it) depend on your localization settings, or those on the tier where the code is running (server?).
Regardless, in a Date control's modified method, I am able to extract the .valueStr() in month/day/year format, and then convert it back to a Date type using str2Date(.., 213), where 213 means month/day/year.
Perhaps instead of using .valueStr() which may not produce a predictable results across all users and environments, try extracting the .dateValue() and then using date2Str(..) to format it precisely according to how your str2Date(..) function will expect it. The result should be more reliable and work as expected.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,186 Super User 2024 Season 2
Martin Dráb 227,996 Super User 2024 Season 2
nmaenpaa 101,148