?
Solved

Using the ColdFusion Date Functions To Display Future Dates

Posted on 2003-11-03
11
Medium Priority
?
3,380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 total points
ID: 9669646
and offcourse give the input fields a name and a value
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
Suggested Courses

764 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