Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default International Date formatting

Hi,
I'm trying to add some days build a macro that adds days to a date
from an existing excel file.
However, the excel file may come from multiple sources and the way
they organize the date may come in different formats (dd/mm/yyyy or mm/
dd/yyyy). When I open the file in Excel (mine is configured to be mm/
dd/yyyy) it automatically assumes that format and the ones that do not
fit are changed to fit.

Is there a way for Excel to transform the date into its numerical
value before it changes the format independently of the format the
user used (and sometimes the date itself) so I can manipulate the
information?

Thanks in advance,

Daniel F. Uribe
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default International Date formatting

hi,

Sub Macro1()
For Each c In Range("A1:A10")
If IsDate(c) Then
' MsgBox "it is a true date"
Else
Range(c.Address) = DateSerial(Right(c, 4), Mid(c, 4, 2), Left(c, 2))
End If
Next
End Sub

--
isabelle


Le 2012-11-22 12:28, Daniel a écrit :
Hi,
I'm trying to add some days build a macro that adds days to a date
from an existing excel file.
However, the excel file may come from multiple sources and the way
they organize the date may come in different formats (dd/mm/yyyy or mm/
dd/yyyy). When I open the file in Excel (mine is configured to be mm/
dd/yyyy) it automatically assumes that format and the ones that do not
fit are changed to fit.

Is there a way for Excel to transform the date into its numerical
value before it changes the format independently of the format the
user used (and sometimes the date itself) so I can manipulate the
information?

Thanks in advance,

Daniel F. Uribe


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default International Date formatting

On Nov 22, 2:26*pm, isabelle wrote:
hi,

Sub Macro1()
For Each c In Range("A1:A10")
* If IsDate(c) Then
* * ' MsgBox "it is a true date"
* Else
* *Range(c.Address) = DateSerial(Right(c, 4), Mid(c, 4, 2), Left(c, 2))
* End If
Next
End Sub

--
isabelle

Le 2012-11-22 12:28, Daniel a crit :







Hi,
I'm trying to add some days build a macro that adds days to a date
from an existing excel file.
However, the excel file may come from multiple sources and the way
they organize the date may come in different formats (dd/mm/yyyy or mm/
dd/yyyy). *When I open the file in Excel (mine is configured to be mm/
dd/yyyy) it automatically assumes that format and the ones that do not
fit are changed to fit.


Is there a way for Excel to transform the date into its numerical
value before it changes the format independently of the format the
user used (and sometimes the date itself) so I can manipulate the
information?


Thanks in advance,


Daniel F. Uribe


Thanks for the help Isabelle, but I think I did not explained my
problem well.

I am receiving a file with the format (dd/mm/yyyy) but it may be open
by a computer that uses the same format for date or can use (mm/dd/
yyyy).

Here's an example of what may happen with a date if it is opened by a
computer with the format (dd/mm/yyyy) or with (mm/dd/yyyy)

Original Format (dd/mm/yyyy) (mm/dd/yyyy)
6/11/2012 41219 41071
2/11/2012 41215 40950
2/11/2012 41215 40950
13/11/2012 41226 #VALUE!
14/11/2012 41227 #VALUE!
1/11/2012 41214 40919

As it can be seen the numerical value of the date changes depending on
what computer opens it, and in some cases it may not consider the date
correct while in other cases it simply changes it.

What I want to know, is if it is possible when a file is received, to
interpret the dates by its numerical value directly so that there is
no chance to misinterpret the information (without previously knowing
what the original format of the date was).

Thanks,

Daniel
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default International Date formatting

Daniel wrote:

Here's an example of what may happen with a date if it is opened by a
computer with the format (dd/mm/yyyy) or with (mm/dd/yyyy)

Original Format (dd/mm/yyyy) (mm/dd/yyyy)
6/11/2012 41219 41071
2/11/2012 41215 40950
2/11/2012 41215 40950
13/11/2012 41226 #VALUE!
14/11/2012 41227 #VALUE!
1/11/2012 41214 40919



So it is not an Excel file.

Probably you try to import text file, and depending on local settings
first date will be interpreted as June 11th or November 6th.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,045
Default International Date formatting

On Thu, 22 Nov 2012 09:28:42 -0800 (PST), Daniel wrote:

Hi,
I'm trying to add some days build a macro that adds days to a date
from an existing excel file.
However, the excel file may come from multiple sources and the way
they organize the date may come in different formats (dd/mm/yyyy or mm/
dd/yyyy). When I open the file in Excel (mine is configured to be mm/
dd/yyyy) it automatically assumes that format and the ones that do not
fit are changed to fit.

Is there a way for Excel to transform the date into its numerical
value before it changes the format independently of the format the
user used (and sometimes the date itself) so I can manipulate the
information?

Thanks in advance,

Daniel F. Uribe


You are leaving something out.

If the files you are importing are Excel files, with "real" dates, the nationality of the computer on which the file was created should not be an issue. It should already be there as a numerical value. There might be an issue, however, if some of the Excel files are using the 1904 date system.
However, if the files you are importing are text files, then you need to do the conversion using the "text to columns" or "text import" wizard.
If the file is a .txt file, opening it should bring up the text-to-columns wizard where there is a step at which you can specify the format of the date column.
If the file is a .csv file, you can either change it to a .txt file (merely by changing the suffix), or choose to "import" the file rather than open it, which should open the import wizard, giving the same functionality.

If the above does not help, please provide a more complete description of exactly what is going on.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default International Date formatting

Thank you Ron, that seemed to be the problem, Text disguising as a date. I'll see what I can do to work around it.

Daniel

On Thursday, November 22, 2012 7:48:44 PM UTC-5, Ron Rosenfeld wrote:
On Thu, 22 Nov 2012 09:28:42 -0800 (PST), Daniel wrote:



Hi,


I'm trying to add some days build a macro that adds days to a date


from an existing excel file.


However, the excel file may come from multiple sources and the way


they organize the date may come in different formats (dd/mm/yyyy or mm/


dd/yyyy). When I open the file in Excel (mine is configured to be mm/


dd/yyyy) it automatically assumes that format and the ones that do not


fit are changed to fit.




Is there a way for Excel to transform the date into its numerical


value before it changes the format independently of the format the


user used (and sometimes the date itself) so I can manipulate the


information?




Thanks in advance,




Daniel F. Uribe




You are leaving something out.



If the files you are importing are Excel files, with "real" dates, the nationality of the computer on which the file was created should not be an issue. It should already be there as a numerical value. There might be an issue, however, if some of the Excel files are using the 1904 date system.

However, if the files you are importing are text files, then you need to do the conversion using the "text to columns" or "text import" wizard.

If the file is a .txt file, opening it should bring up the text-to-columns wizard where there is a step at which you can specify the format of the date column.

If the file is a .csv file, you can either change it to a .txt file (merely by changing the suffix), or choose to "import" the file rather than open it, which should open the import wizard, giving the same functionality.



If the above does not help, please provide a more complete description of exactly what is going on.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,045
Default International Date formatting

On Thu, 22 Nov 2012 17:13:08 -0800 (PST), wrote:

Thank you Ron, that seemed to be the problem, Text disguising as a date. I'll see what I can do to work around it.

Daniel


Glad to help. Post back with more details if you require further assistance.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
date handling problem with International issues Brian Murphy Excel Programming 2 May 27th 10 10:59 PM
International date format and user form James Price at Premier Excel Programming 0 April 6th 09 08:21 AM
International/Date issue Niek Otten Excel Programming 5 July 22nd 08 08:16 AM
International number formatting in Excel 2007 Albert[_3_] Excel Discussion (Misc queries) 1 April 19th 08 01:40 PM
International Date Conversion to Values Ligaya Excel Programming 2 July 26th 06 02:48 PM


All times are GMT +1. The time now is 11:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"