You need to sign in to do that
Don't have an account?
nicloz
Add one hour to datetime field
Dears
Please could help me the way to add one hour and get one hour less in another datetime field? I need to do that because the process need to track the time one hour less in the case of start time and one more in the end time.
Format: 2010-04-22T12:12:00.000
Type: Datetime
Best Regards
Did you try the Datetime methods? if no please check the following:-
The following are the instance methods for Datetime.
1. Function Name - addDays Argument - Integer addlDays where addlDays are the days to be added.
Description- Adds the specified number of addlDays to a Datetime.
For example:
datetime myDate =datetime.newInstance(1960, 2, 17);
datetime newDate = mydate.addDays(2);
2. Function Name - addHours Argument - Integer addlHours where addlHours are the hours to be added.
Description- Adds the specified number of addlHours to a Datetime.
For example:
datetime myDate =datetime.newInstance(1960, 2, 17);
datetime newDate = mydate.addHours(1);
Alternatively you can extract the day, month, year, hour, second, minutes, then say increment or decrement the hour as per your requirement and create a new instance of the datetime.
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.