Solved

Using the ColdFusion Date Functions To Display Future Dates

Posted on 2003-11-03
11
3,351 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
 
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to Eclipse 16 118
Autoresponder for Whole Domain in Plesk/Cpanel 2 68
Problem to Popup 37 102
app server have enough resources... 2 24
Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
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.
The purpose of this video is to demonstrate how to connect a WordPress website to Google Analytics. 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 :…
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…

920 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

16 Experts available now in Live!

Get 1:1 Help Now