Non-standard Date Formats Follow

0
Avatar
Legacy Poster

I'm working in an Automotive Manufacturing environment and they have their own way that they want the dates formatted.

I'm receiving an SQL Database date format (2011-08-17) that I need to convert to a non-standard date format (17AUG2011). The output date format must be "2-digit day (zero padded)", "3-char Abbreviated Month", and "4-digit Year" with no separators between them.

My data source is a database field which is not the current system date.

I'm guessing that VB Scripting will be required but haven't been able to come up with the proper output using standard VB Scripts.

Any help would be greatly appreciated.

Robert Stark

2 comments

0
Avatar
Gene Henson
Moderator
Comment actions Permalink

Hello,

You can use the following script to build the correct date:


[quote]
'These variables hold each part of the date and the date to be modified
dim sDay, sMonth, sYear, sDate

'Set this variable to your database field that holds the date
sDate = NOW

'Here we build the day, month, and year separately
sDay = IIF(len(DatePart("d",sDate)<2), 0 & DatePart("d", sDate), DatePart("d", sDate))
sMonth = MonthName(DatePart("m", sDate), True)
sYear = DatePart("yyyy", sDate)

'Then we just combine the three values
value = sday & sMonth & sYear
[/quote]

I split it up so that you can see each part of the date being built in case you want to adjust anything.

Just set the sDate variable to whatever field holds the date that needs to be modified.

Hope that helps!
0
Avatar
Legacy Poster
Comment actions Permalink

Thanks for the help Gene.

It appears to be passsing the data properly but when I look at the label format in the editor, it shows "<script ERROR>" where my date should be on the label.

That appears to only be a cosmetic issue though.

Robert

Please sign in to leave a comment.