Set the value of a DateTime in VL?

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Set the value of a DateTime in VL?

Post 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'
Art Tostaine
User avatar
Dino
Posts: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Set the value of a DateTime in VL?

Post 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' 
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Set the value of a DateTime in VL?

Post by atostaine »

Thanks. It displays with the - on the IBM i. I wonder how other DB's display the value?
Art Tostaine
User avatar
Dino
Posts: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Set the value of a DateTime in VL?

Post 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
Post Reply