Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shorter way to get the date without time in Coldfusion

Tags:

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?

like image 713
Nick Petrie Avatar asked Mar 21 '17 13:03

Nick Petrie


People also ask

How do you find the current date in ColdFusion?

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.

How do I change the date format in ColdFusion?

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.

Which a date format model gives three letter abbreviation of day of week?

ddd : Day of the week as a three-letter abbreviation.


1 Answers

You can use dateCompare with a 3rd argument of d to only compare the date itself

dateCompare(date1, date2, 'd')
like image 156
Matt Busche Avatar answered Sep 21 '22 10:09

Matt Busche