It is just a matter of paying with the individual time values to get what you need.
The hour is always 59 minutes past the current hour minus 1.
<CFIF LookingAt IS "Day">
<CFSET Today =
CreateDateTime(Year(Now()),Month(Now()),Day(Now()),Hour(DateAdd("H",-1,Now()))>),59,0)>
<CFSET LastWeek = DateAdd("N",1,DateAdd("D",-1,Today))>
</CFIF>
----- Original Message -----
From: ColdFusion Programmer
To: CF-Talk
Sent: Wednesday, July 30, 2003 1:00 PM
Subject: [cftalk] calculating the date and time.
not quite as I was expecting. Take the current time, its 11:55 am GMT, I want the
result to be
(29 Jul 2003 11:00 - 30 Jul 2003 10:59)
><CFIF LookingAt IS "Day">
><CFSET Today = CreateDateTime(Year(Now()),Month(Now()),Day(Now()),9,59,
>0)>
><CFSET LastWeek = DateAdd("N",1,DateAdd("D",-1,Today))>
></CFIF>
>
>----- Original Message -----
>From: ColdFusion Programmer
>To: CF-Talk
>Sent: Wednesday, July 30, 2003 12:48 PM
>Subject: [cftalk] calculating the date and time.
>
>
>Spot on Allan, this is what I was trying to do. Can you show me how to
>calclulate the from-to date time in the last 24 hours
>
>In the last 24 hours (29 Jul 2003 10:00 - 30 Jul 2003 09:59)
>
>Many Thanks
>Allan
>
>><CFIF LookingAt IS "Week">
>
>><CFSET Today = CreateDateTime(Year(Now()),Month(Now()),Day(Now()),0,
>59,
>>0)>
>
>><CFSET LastWeek = DateAdd("N",1,DateAdd("D",-7,Today))>
>></CFIF>
>>
>>I haven't tested this so there maybe small errors but something like
>
>>this??
>
>>----- Original Message -----
>
>>From: ColdFusion Programmer
>
>>To: CF-Talk
>
>>Sent: Wednesday, July 30, 2003 12:24 PM
>
>>Subject: [cftalk] calculating the date and time.
>>
>>
>
>>How do I get the calculate the from time to start at 01:00 am and the
>
>>to time to end at 00:59 am. Can you please show me how to get the
>date
>>and time in the format mentioned below
>>
>
>>In the last 7 days (23 Jul 2003 01:00 - 30 Jul 2003 00:59)
>>
>>
>
>>>> I was hoping somebody could help me. I'm trying to
>
>>>> display the date and time. This is how I want to
>
>>>> display it:
>
>>>>
>
>>>> If the current time is 10:05, I want to display the
>
>>>> time in this format:
>
>>>>
>
>>>> In the last hour (09:05 - 10:04)
>
>>>>
>
>>>> If the current time is 10:05 and the date is 30.July,
>
>>>> I want to display the date time in this format:
>
>>>>
>
>>>> In the last 24 hours (29 Jul 2003 10:00 - 30 Jul 2003
>
>>>> 09:59)
>
>>>>
>
>>>> If the current time is 10:05 and the date is 30.July,
>
>>>> I want to display the date time in this format:
>
>>>>
>
>>>> In the last 7 days (23 Jul 2003 01:00 - 30 Jul 2003
>
>>>> 00:59)
>
>>>>
>
>>>> If the current time is 10:05 and the date is 30.July,
>
>>>> I want to display the date time in this format:
>
>>>>
>
>>>> In the last 30 days (30 Jun 2003 01:00 - 30 Jul 2003
>
>>>> 00:59)
>
>>>
>
>>>Look into DateAdd() - you can add any amount of time to a date,
>from
>
>>>seconds to years
>
>>>
>
>>>If you want to remove 7 days, you can just do DateAdd("d", -7,
>>Now())
>
>>>
>
>>>Hope this helps
>
>>>
>
>>>
>
>>>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community.
http://www.fusionauthority.com/ads.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4