Select to view content in your preferred language

VBScript label expression for dates.

4643
2
Jump to solution
06-12-2012 11:04 AM
PaulHuffman
Frequent Contributor
I thought I could reformat a date variable to drop the year for a map label but all I can get from the label expression advanced box is "The expression contains an error. Modify the expression and try again."  Tried

FormatDateTime([StartDate], 1)

and

Function ShortDate ( [StartDate] )
  ShortDate = FormatDateTime([StartDate],1)
End Function

where StartDate is a date item in my table formated mm/dd/yyyy For the second FormatDateTime argument, I've tired 1 and 0.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor
I'm able to get the formatted date for my date field [SUR_DATE] in the label using the line

FormatDateTime([SUR_DATE])

To drop the year, I had use the syntax

Month( [SUR_DATE] ) & "/" & Day([SUR_DATE])

View solution in original post

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor
I'm able to get the formatted date for my date field [SUR_DATE] in the label using the line

FormatDateTime([SUR_DATE])

To drop the year, I had use the syntax

Month( [SUR_DATE] ) & "/" & Day([SUR_DATE])
0 Kudos
PaulHuffman
Frequent Contributor
Thanks, Ken, that's working for me.

But the other thing I was trying to do to make the same label was to create a new item and use the field calculator and python to calculate the shorter date string. I thought I knew more about python but I couldn't get the syntax right.  It seems like you'd use strftime, but maybe it doesn't work because the source item is already a date, not a string.
0 Kudos