Field Calculator Format Function

2700
1
Jump to solution
06-24-2013 07:40 AM
OleksandrChubatyy
New Contributor
Hi

Format function in VB returns a type mismatch error.
The expression I am trying to execute is like this: Date_Str_Field = Format("06/24/2013", "dd-mm-yyyy").
Does not ArcMAp 10.1 support this function anymore?

Thanks
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RichardFairhurst
MVP Honored Contributor
Hi

Format function in VB returns a type mismatch error.
The expression I am trying to execute is like this: Date_Str_Field = Format("06/24/2013", "dd-mm-yyyy").
Does not ArcMAp 10.1 support this function anymore?

Thanks


Format is a VBA function, not a VB Script function and is no longer supported by ArcMap 10.1.  VB script has a FormatDateTime function, but if the format does not match your regional settings, it is not at all easy to force the date into a custom format.  You basically have to write all of the parsing and formatting steps yourself for each date component, which is tedious.

Python should be something like:

import datetime
Date_Str_Field = datetime.datetime.strptime('06/24/2013', '%m/%d/%Y').date().strftime('%d-%m-%Y')

View solution in original post

0 Kudos
1 Reply
RichardFairhurst
MVP Honored Contributor
Hi

Format function in VB returns a type mismatch error.
The expression I am trying to execute is like this: Date_Str_Field = Format("06/24/2013", "dd-mm-yyyy").
Does not ArcMAp 10.1 support this function anymore?

Thanks


Format is a VBA function, not a VB Script function and is no longer supported by ArcMap 10.1.  VB script has a FormatDateTime function, but if the format does not match your regional settings, it is not at all easy to force the date into a custom format.  You basically have to write all of the parsing and formatting steps yourself for each date component, which is tedious.

Python should be something like:

import datetime
Date_Str_Field = datetime.datetime.strptime('06/24/2013', '%m/%d/%Y').date().strftime('%d-%m-%Y')
0 Kudos