[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Using the ColdFusion Date Functions To Display Future Dates

Posted on 2003-11-03
11
Medium Priority
?
3,389 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 200 total points
ID: 9669646
and offcourse give the input fields a name and a value
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
What You Need to Know when Searching for a Webhost Provider
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…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. 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 : Go t…
Suggested Courses

834 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