How to export the start date and time in MS Project?

68 views Asked by At

I am working with Progress 4gl(11.7) version where I came across a scenario where We are doing Job/task export from application to MS project. Everything is working fine but we have a problem in Percentage Complete where if the job/task duration is 1.5 days after exporting to MS Project its calculating 2 days which is changing the Percent Complete automatically. So I figured may be as we are exporting only date not time, calculation is also happening in Dates.

Now I tried to export the time as well in the start and end date. This is what I have tried

DEF VAR objPrj       AS COM-HANDLE NO-UNDO.
DEF VAR objActivePrj AS COM-HANDLE NO-UNDO.

CREATE "MSProject.Application" objPrj. /*Created a project object*/
objActivePrj = objPrj:ActiveProject(). /*Activated the project*/

objActiveTask = objActivePrj:Tasks:ADD("", vTaskId).  /*Add the Task*/
objActiveTask = objActivePrj:Tasks:Item(vTaskId).  /*Add the Task ID*/
objActiveTask:START  = DATETIME("05-30-2020 03:30 pm"). /*Added hardcoded date and time*/

which is working perfectly fine I am able to export this time in the MS Project.

Now if I do the similar assignment something like

objActiveTask:START  = DATETIME(STRING(02/24/24,"99-99-9999") + " " +  STRING(15:00, "HH:MM:SS"))

Where STRING(02/24/24,"99-99-9999") will be replaced by date variable and STRING(15:00, "HH:MM:SS") will be replaced by time variable.

The time and date is exporting but its exporting wrong like 02/29/2024 00:00 in MS project.

What could we do to export the time and the date correctly? If you have worked on any kind MS project Exporting Program please guide me. Thank you very much.

3

There are 3 answers

0
Tom On

You could replace STRING(15:00, "HH:MM:SS") with "15:00".

See example in ABL Dojo.

4
Tom Bascom On

In your hard-coded case you have:

objActiveTask:START = DATETIME("05-30-2020 03:30 pm").

You say that that works, so I will trust that it does.

Your "something like" case that doesn't work looks like this:

objActiveTask:START = DATETIME(STRING(02/24/24,"99-99-9999") + " " +  STRING(15:00, "HH:MM:SS")).

Which does not compile (so it is a mystery how you get a wrong export - you should get nothing at all...). The main problem that I see in the code that you have shared is that 15:00 is not a valid constant. Time values are integer seconds since midnight. So "15:00" should be (( 15 * 3600 ) + ( 0 * 60 ) + 0 )

thus the code should be:

objActiveTask:START = DATETIME(STRING(02/24/24,"99-99-9999") + " " + STRING(15 * 3600 + 0 * 60 + 0, "HH:MM:SS")).

That isn't "wrong" but it would be cleaner to skip all of the string building and just use the date & time directly. DATETIME() supports DATETIME( date, milliseconds ) so a cleaner statement would be:

DATETIME( 02/24/24, ( 15 * 3600 + 0 * 60 + 0)  * 1000 )

or, perhaps:

objActiveTask:START = DATETIME( TODAY, TIME * 1000 ).

or, even:

objActiveTask:START = NOW.
0
nwahmaet On

Any reason why you don't want to use this variant of the DATETIME function?

DATETIME ( month , day , year , hours , minutes 
       [ , seconds[ , milliseconds]] )