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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenate Date

Status
Not open for further replies.

fredong

IS-IT--Management
Joined
Sep 19, 2001
Messages
332
Location
US
I am using CR 10 and I am trying to concatenate a datetime format. I have convert the datetime format to a date format in the File/option/Datetime from a
yyyy-mm-dd 00:00:000 to mm/dd/yyyy. Now I need to create a formula to concate the date. How can this be done in a formula. Below is my syntax that return a datetime error. Please advise. Thanks.


IF {BeginDate} = {EndDate} THEN
{BeginDate}
ELSE
{BeginDate} + " - " + {EndDate}
 
You basically had it:

IF {BeginDate} = {EndDate} THEN
totext({BeginDate},"MM/dd/yyyy")
ELSE
totext({BeginDate},"MM/dd/yyyy") & " - " & totext({EndDate},"MM/dd/yyyy")

-k
 
I tried your syntax that is shown below and I got a return error "Too many arguments have been given to this function" Please advise. Thanks.

IF {BeginDate} = {EndDate}
THEN TOTEXT({BeginDate},"mm/dd/yy")
ELSE
TOTEXT({BeginDate},"mm/dd/yy") & " - " &
TOTEXT({EndDate},"mm/dd/yy")
 
The case on the "mm"s matters. The formula should be:

IF {BeginDate} = {EndDate}
THEN TOTEXT({BeginDate},"MM/dd/yy")
ELSE
TOTEXT({BeginDate},"MM/dd/yy") & " - " &
TOTEXT({EndDate},"MM/dd/yy")

-LB

 
I have changed it to the "MM" and I still got the same error? Any ideas?
 
Initially you said that you needed YYYY, not YY, this changed?

Using lowercase Ms wouldn't cause the error, a lowercase would have produced minutes instead of months, not an error.

btw, you don't need to chane the default of ighoring times to do this.

Try the formula:

totext(currentdate,"MM/dd/yyyy")

Does it error?

If not, then I suspect that the field you are working with is NOT a date, rather a string which has a date stored in it.

Right click the field and select broswe data, it will tell you the dataq type, post it here.

If it's a string, then you need to convert it to a date first, in which case you need to post examples of how it's stored as well.

-k
 
Please copy your actual formula into the thread.

Are begindate and enddate parameters by any chance? If so, make sure that you have them set up as date type parameters.

-LB
 
When I browse the data it showed type String. So which way should I go now. Thanks.
 
As previously requested:

"If it's a string, then you need to convert it to a date first, in which case you need to post examples of how it's stored as well."

I'm not going to keep guessing, please put some effort forth.

-k
 
For somehow my storeprocedure datatype is datetime in the temp table and in crystal it is showing string. Anyway, I am good to go with this below

Thanks everyone I am good to go with this below

IF {BeginDate} = {EndDate}
THEN ({BeginDate},"mm/dd/yy")
ELSE
({BeginDate},"mm/dd/yy") & " - " &
({EndDate},"mm/dd/yy")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top