gsr
01/02/2024, 6:37 PMAdam Cameron
gsr
01/02/2024, 6:39 PMAdam Cameron
Myka Forrest
01/02/2024, 6:44 PMSAPPDateFormat, but seemingly reversing the mm & ddgsr
01/02/2024, 6:44 PMAdam Cameron
THEMONTH= '29';Tim
01/02/2024, 7:00 PMgsr
01/02/2024, 7:39 PMseancorfield
THEDAY and THEMONTH so they are valid you get {ts '2023-12-29 00:00:00'} {ts '2024-12-28 00:00:00'} as output.
As it stands, you get an error because THEMONTH is 29.
If you change the format to SAPPDATEFORMAT= 'dd/mm/yy'; (not yyyy because the if checks for yy) you get an error unless you swap day/month values -- again because month cannot be 29!Adam Cameron
<cfscript>
STARTDT ='12/29/2023';
</cfscript>
<cfset MyDate=#ListToArray(StartDt,"/")#>
<cfset TheDay=MyDate[1]>
<cfset TheMonth=MyDate[2]>
and that is ending in month as 29, quite weirdIn what way is it weird? You're treating the second part of that date as the month, when clearly it's the day of the month.
STARTDT is in format mm/dd/yyyy and your code is pretending it's dd/mm/yyyy, and then... well... that's never gonna work as you found out.
What are you actually trying to achieve here? Forget about code. Articulate it in EnglishMatt Jones
01/02/2024, 9:17 PMgavinbaumanis
01/02/2024, 11:10 PMTHEDAY and THEMONTH
<cfscript>
THEDAY = '29';
THEMONTH = '12';
THEYEAR = '2023';
STARTDT ='12/29/2023';
SAPPDATEFORMAT = 'MM/dd/yyyy';
</cfscript>
But again - this assumes that they code in your gist is EXACTLY the same as what is running in your application.
If it is different in any way - then everyone's advice to you, isn't going to be very helpful.
Let me explain.
IF the real code in your application actually gets the values from a form - or from a database and THEN populates THEDAY and THEMONTH / etc - then - the issue is something completely different.
And I would "guess" (and I can only guess - because of what you have written) - that if that is the case - the issue lies in the way you're getting your date time data in the first place or how you're going about putting the individual parts into those (THEDAY, THEMONTH, THEYEAR) variables.
Lastly about date / time MASKS.
And while it seems that you have the date mask correct in your example - make sure, please, that you realise that for a mask - the date / time parts are Case-Sensitive.
Previously - (I think) in older versions - CFML used to do a whole lot of extra work and try and work out what you meant with your masks - irrespective of the case you chose.
This caught me out a couple of years ago - in that we had really old code that had incorrect casing for the time-parts and now we were noticing there were issues. We were seeing the MONTH where there should be MINUTES.
So it was either we were just really bad at noticing before - OR the CFML engine handled the masking differently in previous versions and perhaps tried to "Guess" what you meant - irrespective of the CASE you used
So if you wrote;
dateTimeFormat(now(), "DD/MM/YYYY HH:MM:SS")
It would work out for you that although you wrote "MM" in the time segment - you really meant to write "nn" and would correctly display your minutes 00-59. We noticed it - when we all of our MINUTES never got above 12!
Anyway - if you need them:
Here are the docs that give you the details about the masks you can use.
Adobe-dateTimeFormat
Lucee-dateTiemFormatgavinbaumanis
01/02/2024, 11:22 PMEndDt will miss everything that happened on the last day - the day STARTS at 000000 and ENDS at 235959
That is you "MIGHT" need to use the time, also and end up with
StartDt2 : YYYY-MM-DD 000000
EndDt : YYYY-MM-DD 235959
At the moment they both have 000000 - in your example.