BookmarkSubscribe
Choose Language Hide Translation Bar

## Need to convert decimal datetime to ddMONYY

I am using a datetime prompt to pull in the start date and end date for my sql query.  The date prompt is using decimal.  How do I convert the decimal to ddMonyy format.  My code is below.  You will see in my select that I have t1.Login_Date with the variable startDT and t1.Login_Date with the variable endDT.  This is where I need to convert the decimal to the date.  I have tried Cast and convert and both together and cannot get it to work.  Any help would be greatly appreciated.

NamesDefaultToHere(1);

// Written by Vince Faller

1 ACCEPTED SOLUTION

Accepted Solutions

## Re: Need to convert decimal datetime to ddMONYY

Here is a simple example to do the conversion you want

``````Names Default To Here( 1 );

theDate = Today();

charDate = Uppercase( Format( theDate, "ddmonyyyy" ) );
Show( charDate );

finalDate = Substr( charDate, 1, 5 ) || Substr( charDate, -2 );
Show( finalDate );``````
Jim
3 REPLIES 3

## Re: Need to convert decimal datetime to ddMONYY

NamesDefaultToHere(1);

// Written by Vince Faller
// Makes a calendar come up on a numeditbox (defaults to now)
// Note, this only works on JMP 11 or above
dateBox = Function(
{timething = Today()},
{newbox},
newbox = Eval(
Substitute(
Name Expr(
Number Edit Box(
timething, // Eval(Sub()) because of JMP quirk
10, // Just need this because JMP doesn't default a width
<<Set function(
Function( {self},
{},
If( Is Missing( self << get ),
self << Set( Eval( DUMMY ) ) // Sets the date to the timething argument
)
)
),
<< Set Format(Format( "m/d/y h:m:s", 23, 0 ) ); // Makes datetime format for the box (gives calendar)
)
),
Expr( DUMMY ), timething
)
);
newbox;
);

nw =
New Window( "Enter Date Range",
LineUpBox(NCol(2),
TextBox("Start DateTime"), start = dateBox(Today() - InDays(12)),
TextBox("End DateTime"), end = dateBox(),
ButtonBox("Cancel", nw << close window), ButtonBox("Get Data", runScript)
));

runScript = Expr(nw<<Close Window;

## Re: Need to convert decimal datetime to ddMONYY

Here is a simple example to do the conversion you want

``````Names Default To Here( 1 );

theDate = Today();

charDate = Uppercase( Format( theDate, "ddmonyyyy" ) );
Show( charDate );

finalDate = Substr( charDate, 1, 5 ) || Substr( charDate, -2 );
Show( finalDate );``````
Jim

## Re: Need to convert decimal datetime to ddMONYY

I was able to incorporate your suggestion into my code. Thanks for the help.