Solved

Using the ColdFusion Date Functions To Display Future Dates

Posted on 2003-11-03
11
3,345 Views
Last Modified: 2013-12-24
When entering information to be stored in the database I want to be able to provide the user with

1 - The current date already entered into either a text box or a list box

2 - in another list box i want to have a number of dates available to the user that are approximately a week or two weeks in front of the current date - this date will act in essence as the 'expiry date'.  This date value will change all the time depending on what the current day is.

For example:  if the current date was 3 November 2003 then the other list box would say 10 November 2003 (one week away) and 17 november (two weeks away) and the user can then select either one or the other?

Cheers
0
Comment
Question by:martywire
  • 4
  • 4
  • 3
11 Comments
 
LVL 10

Expert Comment

by:Mause
Comment Utility
It will be something like this:

<input type="text" value="#dateformat(now(),'yyyy-mm-dd')#">
      
<select name="" size="5">
<option>#dateformat(dateadd('ww',1,now()),'yyyy-mm-dd')#</option>
<option>#dateformat(dateadd('ww',2,now()),'yyyy-mm-dd')#</option>
</select>

Mause
0
 

Author Comment

by:martywire
Comment Utility
Cheers Mause!

You've been most helpful.
0
 
LVL 10

Accepted Solution

by:
Mause earned 50 total points
Comment Utility
and offcourse give the input fields a name and a value
0
 
LVL 4

Expert Comment

by:procept
Comment Utility
Hi,

for the current date in format MM/DD/YYYY:

<input type="text" name="current_date" value="#DateFormat(now(), 'mm/dd/yyyy')#">

For the expiry date:

<select name="expiry_date">
   <option value="#DateFormat(DateAdd("d", 7, now()), 'mm/dd/yyyy')#">
      #DateFormat(DateAdd("d", 7, now()), 'mm/dd/yyyy')#
   </option>
   <option value="#DateFormat(DateAdd("d", 14, now()), 'mm/dd/yyyy')#">
      #DateFormat(DateAdd("d", 14, now()), 'mm/dd/yyyy')#
   </option>
</select>

HTH,

Chris
0
 
LVL 4

Expert Comment

by:procept
Comment Utility
Sorry, Mause posted while I was typing. :-))
0
Scale it in WD Gold

With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

 

Author Comment

by:martywire
Comment Utility
Thank you all for your help.  It is very much appreciated :)
0
 

Author Comment

by:martywire
Comment Utility
Chris,

I have tried running the code that you posted.  The current date appears in the text box with no problems at all but the expiry date drop down option box displays are:

#DateFormat(DateAdd("d", 7, now()), 'mm/dd/yyyy')#
#DateFormat(DateAdd("d", 14, now()), 'mm/dd/yyyy')#

The actual dates do not appear in the drop down box and it is obviously not correct!

Any idea why?
0
 
LVL 4

Expert Comment

by:procept
Comment Utility
Sorry, forgot to put <cfoutput> around the code....
0
 
LVL 10

Expert Comment

by:Mause
Comment Utility
is the select box inside a cfoutput tag??
0
 
LVL 10

Expert Comment

by:Mause
Comment Utility
:) same problem here procept
0
 

Author Comment

by:martywire
Comment Utility
Excellent!  its working now
Thank you.

Will the date be stored in the database as the displayed date even though the CFOUTPUT tags are used?
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

In this short web based tutorial, I wanted to show users how they can still use the powers of FrontPage in conjunction with Expression Web 3.  Even though Microsoft eliminated the use of Web components, we can still use them with FrontPage and edit …
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now