Go Back   MarcomCentral (PTI) and FusionPro User Communities > Support > Issues, Questions, Etc.

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 15th, 2018, 03:33 AM
macfan55 macfan55 is offline
Junior Community Member
 
Join Date: Apr 2011
Location: Netherlands - Emmen
Posts: 34
Default Importing Excel file alters the structure of "Date" in the output

I have a problem in using native excel files with text formatted as "Date"
When I open the file in Excel the column "Date" is filled like 27-04-2012 but after importing it as data source into FusionPro it becomes 27/04/2012 in the output
How can this be solved without altering the native excel file?
Reply With Quote
  #2  
Old August 15th, 2018, 04:43 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Importing Excel file alters the structure of "Date" in the output

Code:
return Field("Date").replace(/\//g, '-');
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #3  
Old August 16th, 2018, 01:42 AM
macfan55 macfan55 is offline
Junior Community Member
 
Join Date: Apr 2011
Location: Netherlands - Emmen
Posts: 34
Default Re: Importing Excel file alters the structure of "Date" in the output

Thanks for answering so quickly.
Unfortunately I made a mistake in my first example.
Not only it alters the - in excel to / in FusionPro.
But it also switches the first and second number in the field.
For the english speaking world this is correct but in the Netherlands the sequence of a date-field is: DD/MM/YYYY
In excel the date is read correct like 20-09-1926 (DD/MM/YYYY)
"Under the Hood" in the excel file itself this is representated as 9760
This is the 9760-th day after 0-0-1900
After importing the excel file in FusionPro it reads like 9/20/1926 (MM/DD/YYYY)
With the given first solution (thanks for that) I can change that to 9-20-1926
but this has to be 20-9-1926
Has anyone any idea how to tackle this conversion problem without altering the excel file itself? In FusionPro I could not find any preference on how to interpret the numbering system of an excel date-field to the correct formatting of a country like the Netherlands.
Thanks in advance.
Reply With Quote
  #4  
Old August 16th, 2018, 09:31 AM
ScottHillock ScottHillock is offline
Regular Contributor
 
Join Date: Mar 2010
Posts: 91
Default Re: Importing Excel file alters the structure of "Date" in the output

Code:
var DateSplit = Field("Date").split("/");
return DateSplit[1] + "-" + DateSplit[0] + "-" + DateSplit[2];
Alternatively, you can use javascript's date functions which might be more flexible.

Code:
var d = new Date(Field("Date"));
return d.getDate() + "-" + d.getMonth() + "-" + d.getFullYear();
Reply With Quote
  #5  
Old August 16th, 2018, 12:46 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,369
Default Re: Importing Excel file alters the structure of "Date" in the output

Quote:
Originally Posted by ScottHillock View Post
Code:
var DateSplit = Field("Date").split("/");
return DateSplit[1] + "-" + DateSplit[0] + "-" + DateSplit[2];
Alternatively, you can use javascript's date functions which might be more flexible.

Code:
var d = new Date(Field("Date"));
return d.getDate() + "-" + d.getMonth() + "-" + d.getFullYear();
Or:
Code:
var d = DateFromString(Field("Date"));
return FormatDate(d, "d-m-yyyy");
Or, if you want the day and month to always be two digits (such as "04"):
Code:
var d = DateFromString(Field("Date"));
return FormatDate(d, "dd-mm-yyyy");
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #6  
Old August 17th, 2018, 02:36 AM
macfan55 macfan55 is offline
Junior Community Member
 
Join Date: Apr 2011
Location: Netherlands - Emmen
Posts: 34
Default Re: Importing Excel file alters the structure of "Date" in the output

Thanks for the answers! This has been again a great help for me!
Greetings from the Netherlands
Reply With Quote
Reply

Tags
date, excel, text formatting

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:26 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.