Millisecond DatePart bug

I’m doing some testing on Lucee 6.1.0.243 and found that datePart milliseconds is returning the incorrect values.

datePart(‘l’, ‘2024-12-01T00:00:00.100’);
returns 100

datePart(‘l’, ‘2024-12-01T00:00:00.010’);
returns 100.

datePart(‘l’, ‘2024-12-01T00:00:00.001’);
returns 100.

Milliseconds are clearly trimmed in the same way that hours,minutes,and seconds are. This is obviously an issue, especially when the right is then padded with 0’s after the evaluation.

I’ll happily submit a patch suggestion when time allows. For now though, I just wanted to give a heads up in case someone was noticing some odd trends in report generation and ended up arguing with management that “No! They are the morons, so shut up and get out of my office.” :grinning:

Hmmm, I’d say the String you are passing is a string, and not a date object.

Update: need to correct myself, you are correct! the function is retrieving incorrect milisecond comparing with Lucee 5

I thought so too. To save everyone time, I confirmed the bug using:

dPart100= datePart('l', parseDatetime('2024-12-01 00:00:00.100'));
writeoutput("<br>dPart100=" & dPart100);

 dPart010= datePart('l', parseDatetime('2024-12-01 00:00:00.010'));
writeoutput("<br>dPart010=" & dPart010);

 dPart001= datePart('l', parseDatetime('2024-12-01 00:00:00.001'));
writeoutput("<br>dPart001=" & dPart001);
1 Like

My apologies for the sloppy example.