Split time string to value
(Created page with "I was asked on how to split a string from a textbox to its given hour and minute values. let x='22:12'.split(':'.tochararray) in ( Integer.Parse(x.at0(0)).asstring+' hour...")
 
No edit summary
Line 10: Line 10:
   DateTime.Parse('0001-01-01 '+x.at0(0)+':'+x.at0(1))
   DateTime.Parse('0001-01-01 '+x.at0(0)+':'+x.at0(1))
  )
  )
I later found that another article addresses the same issue in a wider context together with the derived settable attribute here [[Derived settable attributes]].

Revision as of 08:14, 23 January 2020

I was asked on how to split a string from a textbox to its given hour and minute values.

let x='22:12'.split(':'.tochararray) in
(
  Integer.Parse(x.at0(0)).asstring+' hours and '+Integer.Parse(x.at0(1)).asstring+' minutes'
)

Why you may ask? Well consider to have this in a ReverseDerived string representing the clock. Once you have the parts you can update a datetime value with thes for storage

Or maybe like this:

let x='22:12'.split(':'.tochararray) in(
  DateTime.Parse('0001-01-01 '+x.at0(0)+':'+x.at0(1))
)

I later found that another article addresses the same issue in a wider context together with the derived settable attribute here Derived settable attributes.

This page was edited 68 days ago on 02/10/2024. What links here