You need to sign in to do that
Don't have an account?
Feroz
Apex: assign Date/time data type to date datatype
Hello guys,
I'm having a little difficultly
I've a 2 custom fields one with date time data type and the other is date data type.
what I'm trying to do is
variable1 = variable2 + 30 ;
where v1 is date datatype and v2 date/time data type .
basically i want to add date from next 30 days
and Im getting an error as "Illegal assingment from daterime to date
Convert datetime field to date and calculate date field.
variable2 dT = System.now();
Date myDate = date.newinstance(dT.year(), dT.month(), dT.day());
variable1 = myDate + 30;
If this helps, please mark it as best aswer.
Thanks!!
please use below code:-
OUTPUT:-
DEBUG|variable1 2021-09-09 00:00:00
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
try below code. I'm sure your problam will be solved by using it.
don't forget to mark it as best answer.
Thank you
If my solution is usful for you then please mark it as best answer.
Regards
Mukesh