Solved

Using the ColdFusion Date Functions To Display Future Dates

Posted on 2003-11-03
11
3,355 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
ID: 9669638
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
ID: 9669645
Cheers Mause!

You've been most helpful.
0
 
LVL 10

Accepted Solution

by:
Mause earned 50 total points
ID: 9669646
and offcourse give the input fields a name and a value
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 4

Expert Comment

by:procept
ID: 9669655
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
ID: 9669661
Sorry, Mause posted while I was typing. :-))
0
 

Author Comment

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

Author Comment

by:martywire
ID: 9669699
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
ID: 9669734
Sorry, forgot to put <cfoutput> around the code....
0
 
LVL 10

Expert Comment

by:Mause
ID: 9669737
is the select box inside a cfoutput tag??
0
 
LVL 10

Expert Comment

by:Mause
ID: 9669741
:) same problem here procept
0
 

Author Comment

by:martywire
ID: 9669747
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…

806 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