Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8611411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:22:10+00:00 2026-06-12T04:22:10+00:00

Pulling my hair out again… I need to calculate the difference between two dates

  • 0

Pulling my hair out again…

I need to calculate the difference between two dates in days. I’m doing this:

 <cfset d = DateDiff("d", Dateformat( active_apps.app_base_coupon_start, "dd.mm.yyyy"), Dateformat( variables.useDate, "dd.mm.yyyy") )>

With active_apps.app_base_coupon_start = 27.07.2012 and variables.useDate = today = 02.10.2012.

I dumped both values, they are OK. However the dateDiff returns -168 when I was looking for (4 days in July, 31 in August, 30 in September, 2 in October) 67 days.

Question:
Can someone prevent me from losing my remaining hair and tell me what I’m doing wrong here or if there is an easier way to get the difference in days?

EDIT:
Ok, it also works like this:

<cfif DateAdd("d", active_apps.app_grace_time, Dateformat( active_apps.app_base_coupon_start, "dd.mm.yyyy") ) GT now()>
     <cfdump output="e:\s\page\t\dump.txt" label="catch" var="YUP"> 
<cfelse>
    <cfdump output="e:\s\page\t\dump.txt" label="catch" var="NOPE"> 
</cfif>

but I would still like to know, why dateDiff is returning strange values.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:22:12+00:00Added an answer on June 12, 2026 at 4:22 am

    DateDiff("datepart", date1, date2) takes a datepart and two date objects as arguments.

    DateFormat() as Adam Cameron already said returns a string and not a date object.
    ColdFusion is trying to read “27.07.2012” and “02.10.2012” as date objects by trying to apply some known date formats. That’s why “02.10.2012” is interpreted as “Feb 10 2012”.

    I wouldn’t let ColdFusion guess the dateformat of your string. Instead you should create date objects by using CreateDate(year, month, day).

    now() is also a ColdFusion date object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

after pulling my hair out for two days trying to figure this issue out
I've been pulling my hair out for two days trying to put a MySQL
I'm pulling my hair out over this - and it's probably a two second
Pulling my hair out with AJAX once again. This is a simple list plugin
Pulling my hair out over this one. I have one wordpress install at /2009
I've been pulling my hair out with this function. It's a function within a
I am pulling my hair out on this one... I am using the ASIHTTPRequest
I have been pulling my hair out about this since Friday and I am
I'm really pulling my hair out on this one, it seems that I'm having
Pulling my hair out with this simple CSS layout. I have a 2-column fixed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.