DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

formatting time date dd/mmm/yyyy

I am trying to format a date to a specific format DD/MMM/YYYY which is a 2 digit day, 3 character abbrievated month, 4 digit year.  I'm pulling the date out of a csv file generated by the DAS software into a double array.

 

Using the TTR function to convert an odly formatted date to a number and then taking that number and reformatting the date.  Though this proves to be complicated because the format of the date can change from m_d_yyyy to m_dd_yyyy to mm_dd_yyyy and the ttr function can only handle the one format it is given.

 

For a normal format it works, adding another M in the month section does not accieve a 3 character abbrievated month

 

        CALDAT = ttr(1_2_1234,"m_dd_yyyy")
        caldat = str(caldat,"#d/m/yyyy")       ' returns 2/1/1234

        caldat = str(caldat,"#DD/MMM/YYYY")  'returns 2/1/1234

 

Are 3 character abbrievated dates even an option? or do I have to script a string split match loop to convert a date... it seems like reformatting a date should be easier than that.  Does anyone have any graceful ways to easily convert date formats?

0 Kudos
Message 1 of 3
(5,992 Views)

Hello Frizzit,

 

The format string for months to show up as letters instead of numbers is #t in place of #d or #D

 

#dd/ttt/yyyy = 27/Apr/2012

 

The difference between "d" and "D" is explained here:

 

m or M Month
d or D Day
y or Y Year
k Calendar week
h or H Hour
n or N Minute
s or S Second
f Fraction of a second. DIAdem calculates a maximum of 4 places.

 

If you use the uppercase in the format instructions above, DIAdem deletes leading zeros and replaces them with a blank character.

 

The format specification hh:nn:ss results in 01:01:00, the format specification HH:NN:SS shows 1: 1: 0, and the format specification HH:nn:ss displays 1:01:00.

 

Use the following format instructions for months and days of the week:

 

#t, #tt Months with 1, 2 ... Character
#w, #ww Weekdays with 1, 2 ... Character
#T Full Months written
#W Full Weekdays written

 

I hope this helps, let us know if you have additional questions,

 

      Otmar

Otmar D. Foehner
0 Kudos
Message 2 of 3
(5,988 Views)

I didn't see the t's when I was looking, thank you for that.  Standard VB, from my experience is/was MMM.

 

CALDAT = doubarr(c,21)

CALDAT = Replace(CALDAT,"_","/",1)

CALDAT = str(datevalue(CALDAT), "#dd/ttt/yyyy")

 

Works well

0 Kudos
Message 3 of 3
(5,984 Views)