Page 1 of 1

Set the value of a DateTime in VL?

Posted: Fri May 05, 2023 1:14 am
by atostaine
I use DateTime fields all over the place but I guess I've never needed to set the value to anything other than .now.

How can I set a dateTime fields value? This doesn't work:

myDateTime := '2000-01-01-00.00.00' The IDE says datetime field can't be set to string. .asDateTime isn't a valid intrinsic for a literal. In RPG you can use d'2000-01-01-00.00.00'

Re: Set the value of a DateTime in VL?

Posted: Fri May 05, 2023 1:27 am
by Dino
Hi Art

Like this:

Code: Select all

#DATETIMEX := '2023-02-28 01:02:03.004'
* Or this:  #DATETIMEX := '2023-02-28'
* Or this:  #DATETIMEX := '2023-02-28 13:20'
#Edit1.Value := #DATETIMEX.AsString
in your example you have an extra -

Code: Select all

'2000-01-01     -       00.00.00' 

Re: Set the value of a DateTime in VL?

Posted: Fri May 05, 2023 4:54 am
by atostaine
Thanks. It displays with the - on the IBM i. I wonder how other DB's display the value?

Re: Set the value of a DateTime in VL?

Posted: Fri May 05, 2023 6:23 am
by Dino
More details are here. but that is the format that LANSA uses to convert to datetime.
once a datetime field, you dont really care about how the database stores it inside.

only one other thing to be aware is time zones.

more detail here:
https://docs.lansa.com/15/en/lansa015/c ... 1_0070.htm