Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Date format

8 REPLIES 8
Reply
Message 1 of 9
128848
1977 Views, 8 Replies

Date format

Hi!

 

I have a configuration file (.xlsx) where I have put in Client, project number and a date (as a custom iproperty). These cells are linked to the iProperties in the IDWs. The project number and client works well, however im struggling with the date. The date is written dd.mm.yyyy in excel, and Date1 is set to date type.

 

Date1 = GoExcel.CellValue(ThisDoc.Path & "\Project configuration.xlsx", "Sheet1", "D4")

 

When I run the rule Date1 changes type from Date to Number, and inserts a random number.

 

By inserting this code:

Date1 = DateString()

The date is converted to mm-dd-yyyy, but with wrong dates. If I write 15.10.2013 in Excel it will write the date as 08-01-2013. How to get it written lik 15.10.2013?

Cheers!

8 REPLIES 8
Message 2 of 9
Paul-Mason
in reply to: 128848

Have you tried the SAVE AS option and saved the file as XLS format instead of xlsx and the tested it?

 

You may also get a bit more help by posting your question here http://answers.microsoft.com/en-us/office 

==============
Inventor 2023 Pro
HP Z420 workstation
Xeon 3.7Ghz CPU 8 Cores, 64 GB Ram
64bit (The Garbage known as) Windows 10 Pro
AMD FirePro V3900 (ATI FireGL) (1GB RAM)
=================
Ashington Northumberland (UK) ~ Home to the WORLD FAMOUS Pitman Painters Group
Message 3 of 9
Cadmanto
in reply to: 128848

Last time I saw this question this setting worked for the user.  Maybe this will work for you as well.

Go to control panel here.

date.JPG

I know this is a global setting, but maybe through your routine you can tap into this setting.

 

check.PNGIf this solved your issue please mark this posting "Accept as Solution".

Or if you like something that was said and it was helpful, Kudoskudos.PNG are appreciated. Thanks!!!! Smiley Very Happy

 

New EE Logo.PNG

Inventor.PNG     vault.PNG

Best Regards,
Scott McFadden
(Colossians 3:23-25)


Message 4 of 9
blair
in reply to: Cadmanto

Cadmanto is correct, Inventor reads the date format from the Windows region and date settings in the O/S and not any value/setting withing Inventor.

 

 


Inventor 2020, In-Cad, Simulation Mechanical

Just insert the picture rather than attaching it as a file
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Delta Tau Chi ΔΤΧ

Message 5 of 9
Curtis_Waguespack
in reply to: 128848

Hi 128848,

 

Since you're using code to handle the date, you can format the date as needed. Here's a quick example:

 

Dim Date1 As Date
Date1 = GoExcel.CellValue(ThisDoc.Path & "\Project configuration.xlsx", "Sheet1", "D4")
Dim MyDate As String
MyDate = Format(Date1, "dd.MM.yyyy")
MessageBox.Show(MyDate , "iLogic")

 Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 6 of 9
128848
in reply to: Curtis_Waguespack

Got an error trying out your code Curtis.

 

Error on Line 14 : Argument not specified for parameter 'format' of 'Public Shared Function Format(enumType As System.Type, value As Object, format As String) As String'.

Error on Line 14 : Value of type 'Date' cannot be converted to 'System.Type'.

 

The setting in the control panel is set to dd.MM.yyyy.

Message 7 of 9
128848
in reply to: 128848

 

DateTime.Now.ToString("d")

This will give me correct format of the date, but I its not todays date I want to write. Tried to insert a parameter instead of Now, but that did`nt work. Any ideas?

Message 8 of 9
Curtis_Waguespack
in reply to: 128848

Hi 128848,

 

Is it possible that the cell format in the Excel file is causing issues? If so, maybe converting the cell value to a string first, and then converting it to a date is what is needed?

 

'bring in the date from Excel as a string
Dim Date1 As String
Date1 = GoExcel.CellValue(ThisDoc.Path & "\Project configuration.xlsx", "Sheet1", "D4")
'convert string to date 
Dim Date2 As Date
Date2 = Date1
'format date
MyDate = Format(Date2, "dd.MM.yyyy")
'display date to user
MessageBox.Show(MyDate , "iLogic")

 I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 9 of 9
128848
in reply to: 128848

Well, this is akward.

 

The cell was formated as date, with the correct format. Changed it to text, and everything works fine, however im not converting it to a date. Just as a string and everything is in order.

 

Thanks for everybody´s time and comments 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report