In ColdFusion, I can get the current date without time (technically with the time set to 00:00:00) using CreateDate()
. This is useful for comparing two dates, irrespective of time. However, this seems inefficient. For example, to get today's date, I would write:
CreateDate(Year(Now()),Month(Now()),Day(Now())
Is there a more efficient way to do this?
Use the Now() function to obtain the current date and time from the server. Continuing onward, we can customize the date format even more by specifying a mask in the DateFormat() function. The TimeFormat() function is similar to DateFormat(), except, of course, that it returns the time.
Hence, dateformat(now(), "mm-D-yyyy") is the same as dateformat(now(), "mm-d-yyyy") when flag is set to true. By default Capital D is used to specify Day of the year. See example below. ColdFusion (2018 release) Update 3.
ddd : Day of the week as a three-letter abbreviation.
You can use dateCompare
with a 3rd argument of d
to only compare the date itself
dateCompare(date1, date2, 'd')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With