Skip to main content
September 9, 2011
Question

Divide date (newbie question)

  • September 9, 2011
  • 2 replies
  • 804 views

i have 2 datetime

<cfset date1 = "01/01/2011 1:30:00">

<cfset date2 = "01/01/2011 6:00:00">

how can I get the number of 30 min. in that date range.

there are 9 (30min) in that date range.

below is what im trying to do.

<cfset value1 = date2 - date1>

<cfset value2 = value1 / 30 min.>

thanks you in advance.

This topic has been closed for replies.

2 replies

Inspiring
September 9, 2011

Take a look at the date functions. Specifically DateDiff(). You can use it to obtain the total difference in minutes.

DateDiff()

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_c-d_28.html

Functions by Category

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_c-d_28.html

Inspiring
September 9, 2011

Use the datediff() function

September 9, 2011

Thanks,

It was stupid of me. It's been a long week and coudn't even think right.

<cfset date1 = "01/01/2011 1:30:00">

<cfset date2 = "01/01/2011 6:00:00">

<cfset value1 = DateDiff('n',date1,date2)>

<cfset value2 = value1 / 30>

<cfoutput>#value1# - #value2#</cfoutput>

Inspiring
September 9, 2011

We all have those...

Lyndon Patton

405-301-0952

www.ohrc.org

iPhone