Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Now () stumble...

Status
Not open for further replies.

cf59102

Technical User
Jun 5, 2004
25
US
I am trying to see a variable for today's date and then add a month to it to create another variable:

<cfset Variables.DateToday = Now()>

<cfset Variables.DateValReq = DateAdd("m", 1, variables.DateToday)>

However, my output comes out as the following:

Variables.DateToday shows up as January 12, 1900

and

Variables.DateValReq becomes February 12, 1900

It is obvious my DateToday is going awry. Any help would be appreciated.

 
are you using this in a query by chance? My co-worker had a problem like this just the other day. turns out the query didn't have the ' around the date value.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
no am not - just outputting the dates!!
 
This works perfectly fine for me:

Code:
<cfset variables.TodayDate = Now()>
<cfset variables.NextDate = DateAdd("m",1,variables.TodayDate)>

<cfoutput>
Today's Date is #dateformat(variables.TodayDate,"mm/dd/yyyy")# <br>
Next Date is #dateformat(variables.NextDate,"mm/dd/yyyy")#
</cfoutput>

You can view the results here:
[sub]
____________________________________
Just Imagine.
[sub]
 
The code worked fine for me on another machine also. I suspect I might have a variable-name conflict going on. Will do some tests and let you know.

Thanks for the response.
 
... Have you tried outputting #Now()# on that machine? Just to see what you get?

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
That was going to be my suggestion as well. If Now() outputs a date in 1900, then perhaps that is the BIOS time that is set for that computer... If it works on another machine is is certainly something in the machine and not the code.

Good luck,
MG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top