PC Review


Reply
Thread Tools Rate Thread

Convert American Date to Australian Date format

 
 
Noemi
Guest
Posts: n/a
 
      3rd Dec 2008
Hi
Does anyone know how to convert american dates into australian dates using
code or if not code then in excel.

My main reason for wanting this is to run a comparison between the 2 dates
to see if the match however if the american date has a lower number then the
program assumes it is an australian date.

Thanks
Noemi
 
Reply With Quote
 
 
 
 
OssieMac
Guest
Posts: n/a
 
      3rd Dec 2008
Hi Noemi,

The following was a recent reply. I have left the contributors name on the
bottom to give credit where credit is due.

The following macro converts date strings and values in the selected range
between mm/dd/yyyy and dd/mm/yyyy. The output is in the
form of date values that you can format as dates via Format|Cells|Number|Date.

Sub ConvertDateFormat()
Dim DtRange As Range
Dim oCell As Range
Dim oTxt As String
If Selection.Cells.Count = 1 Then
Set DtRange = ActiveCell
Else
Set DtRange = Selection
End If
With Application
On Error Resume Next ' In case there are no xlConstants or convertible
dates in DtRange
For Each oCell In DtRange.SpecialCells(xlConstants)
oTxt = oCell.Text
If UBound(Split(oTxt, "/")) = 2 Then _
oCell.Value = CDate(Split(oTxt, "/")(1) & "/" & Split(oTxt, "/")(0) & "/"
& Split(oTxt, "/")(2))
Next oCell
End With
End Sub

Note that no conversion is performed if the date is embedded in a formula or
the output would be an invalid date.

--
Cheers
macropod
[MVP - Microsoft Word]


--
Regards,

OssieMac


"Noemi" wrote:

> Hi
> Does anyone know how to convert american dates into australian dates using
> code or if not code then in excel.
>
> My main reason for wanting this is to run a comparison between the 2 dates
> to see if the match however if the american date has a lower number then the
> program assumes it is an australian date.
>
> Thanks
> Noemi

 
Reply With Quote
 
Noemi
Guest
Posts: n/a
 
      3rd Dec 2008
Thanks OssieMac however I do not understand where oCell is getting it's
information from, it keeps showing cell A1, how do I change this.

Thanks
Noemi

"OssieMac" wrote:

> Hi Noemi,
>
> The following was a recent reply. I have left the contributors name on the
> bottom to give credit where credit is due.
>
> The following macro converts date strings and values in the selected range
> between mm/dd/yyyy and dd/mm/yyyy. The output is in the
> form of date values that you can format as dates via Format|Cells|Number|Date.
>
> Sub ConvertDateFormat()
> Dim DtRange As Range
> Dim oCell As Range
> Dim oTxt As String
> If Selection.Cells.Count = 1 Then
> Set DtRange = ActiveCell
> Else
> Set DtRange = Selection
> End If
> With Application
> On Error Resume Next ' In case there are no xlConstants or convertible
> dates in DtRange
> For Each oCell In DtRange.SpecialCells(xlConstants)
> oTxt = oCell.Text
> If UBound(Split(oTxt, "/")) = 2 Then _
> oCell.Value = CDate(Split(oTxt, "/")(1) & "/" & Split(oTxt, "/")(0) & "/"
> & Split(oTxt, "/")(2))
> Next oCell
> End With
> End Sub
>
> Note that no conversion is performed if the date is embedded in a formula or
> the output would be an invalid date.
>
> --
> Cheers
> macropod
> [MVP - Microsoft Word]
>
>
> --
> Regards,
>
> OssieMac
>
>
> "Noemi" wrote:
>
> > Hi
> > Does anyone know how to convert american dates into australian dates using
> > code or if not code then in excel.
> >
> > My main reason for wanting this is to run a comparison between the 2 dates
> > to see if the match however if the american date has a lower number then the
> > program assumes it is an australian date.
> >
> > Thanks
> > Noemi

 
Reply With Quote
 
Noemi
Guest
Posts: n/a
 
      3rd Dec 2008
Thanks OssieMac

However I am not sure how oCell is getting its data from, it keeps refering
to cell A1 which is not what I want.

Can you help clarify.

Thanks
Noemi

"OssieMac" wrote:

> Hi Noemi,
>
> The following was a recent reply. I have left the contributors name on the
> bottom to give credit where credit is due.
>
> The following macro converts date strings and values in the selected range
> between mm/dd/yyyy and dd/mm/yyyy. The output is in the
> form of date values that you can format as dates via Format|Cells|Number|Date.
>
> Sub ConvertDateFormat()
> Dim DtRange As Range
> Dim oCell As Range
> Dim oTxt As String
> If Selection.Cells.Count = 1 Then
> Set DtRange = ActiveCell
> Else
> Set DtRange = Selection
> End If
> With Application
> On Error Resume Next ' In case there are no xlConstants or convertible
> dates in DtRange
> For Each oCell In DtRange.SpecialCells(xlConstants)
> oTxt = oCell.Text
> If UBound(Split(oTxt, "/")) = 2 Then _
> oCell.Value = CDate(Split(oTxt, "/")(1) & "/" & Split(oTxt, "/")(0) & "/"
> & Split(oTxt, "/")(2))
> Next oCell
> End With
> End Sub
>
> Note that no conversion is performed if the date is embedded in a formula or
> the output would be an invalid date.
>
> --
> Cheers
> macropod
> [MVP - Microsoft Word]
>
>
> --
> Regards,
>
> OssieMac
>
>
> "Noemi" wrote:
>
> > Hi
> > Does anyone know how to convert american dates into australian dates using
> > code or if not code then in excel.
> >
> > My main reason for wanting this is to run a comparison between the 2 dates
> > to see if the match however if the american date has a lower number then the
> > program assumes it is an australian date.
> >
> > Thanks
> > Noemi

 
Reply With Quote
 
OssieMac
Guest
Posts: n/a
 
      3rd Dec 2008
Hi Noemi,

You have to select the range first. That is what the following code is
about. It either sets the range to a single selected cell or a selected range.

If Selection.Cells.Count = 1 Then
Set DtRange = ActiveCell
Else
Set DtRange = Selection
End If


--
Regards,

OssieMac


"Noemi" wrote:

> Thanks OssieMac
>
> However I am not sure how oCell is getting its data from, it keeps refering
> to cell A1 which is not what I want.
>
> Can you help clarify.
>
> Thanks
> Noemi
>
> "OssieMac" wrote:
>
> > Hi Noemi,
> >
> > The following was a recent reply. I have left the contributors name on the
> > bottom to give credit where credit is due.
> >
> > The following macro converts date strings and values in the selected range
> > between mm/dd/yyyy and dd/mm/yyyy. The output is in the
> > form of date values that you can format as dates via Format|Cells|Number|Date.
> >
> > Sub ConvertDateFormat()
> > Dim DtRange As Range
> > Dim oCell As Range
> > Dim oTxt As String
> > If Selection.Cells.Count = 1 Then
> > Set DtRange = ActiveCell
> > Else
> > Set DtRange = Selection
> > End If
> > With Application
> > On Error Resume Next ' In case there are no xlConstants or convertible
> > dates in DtRange
> > For Each oCell In DtRange.SpecialCells(xlConstants)
> > oTxt = oCell.Text
> > If UBound(Split(oTxt, "/")) = 2 Then _
> > oCell.Value = CDate(Split(oTxt, "/")(1) & "/" & Split(oTxt, "/")(0) & "/"
> > & Split(oTxt, "/")(2))
> > Next oCell
> > End With
> > End Sub
> >
> > Note that no conversion is performed if the date is embedded in a formula or
> > the output would be an invalid date.
> >
> > --
> > Cheers
> > macropod
> > [MVP - Microsoft Word]
> >
> >
> > --
> > Regards,
> >
> > OssieMac
> >
> >
> > "Noemi" wrote:
> >
> > > Hi
> > > Does anyone know how to convert american dates into australian dates using
> > > code or if not code then in excel.
> > >
> > > My main reason for wanting this is to run a comparison between the 2 dates
> > > to see if the match however if the american date has a lower number then the
> > > program assumes it is an australian date.
> > >
> > > Thanks
> > > Noemi

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DATEVALUE, etc. and Australian date format LProegler Microsoft Excel Worksheet Functions 1 26th Mar 2008 01:56 AM
Convert European Date format to American Format =?Utf-8?B?QWxiZXJ0?= Microsoft Excel Misc 3 21st Aug 2007 10:02 PM
australian date format =?Utf-8?B?S2FybGluZQ==?= Microsoft Excel Misc 1 24th Mar 2006 12:31 AM
Australian date format in Excel 2000 =?Utf-8?B?QnJpYW4gSm9uZXM=?= Microsoft Excel Misc 2 30th Mar 2005 06:13 AM
Excel 2000 date format cannot be set to Australian date format =?Utf-8?B?QnJpYW4gSm9uZXM=?= Microsoft Excel Misc 1 30th Mar 2005 06:03 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:36 AM.