Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ sahipro.com with your query.

Change date from MM/DD/YYYY to YYYY-MM-DD

seanog1888seanog1888 Members
edited June 2014 in Sahi - Open Source
Hi

I have a variable date in the format of 'OCT/18/2013' which i need to convert to '2013-10-18' so that i can pass it to an SQL query in my code in order to query the DB.

The code i have at the minute is:

function buildIntradayQuery($participant, $grantID, $grantType, $grantDate, $expireDate, $env){

try{

var $PRTC_ID = "'" + $participant +"'";
var $GRANT_T = "'" + $grantType +"'";
var $GRANT_ID = "'" + $grantID +"'";
var $GRANT_D = "'" + $grantDate +"'";
var $EXPIRE_D = "'" + $expireDate +"'";
var $TABLE;

if($env == "Shared") {
$TABLE = "table4";
} else if ($env == "Alpha") {
$TABLE = "table4";
}

var $selectSQL = "select * from " + $TABLE + " WHERE SUB_PRODUCT_TY_C = " + $GRANT_T + " and PRODUCT_ID = " + $GRANT_ID + " and GRANT_D = " + $GRANT_D + " and EXP_D = " + $EXPIRE_D + " and PRTC_ID = " + $PRTC_ID;

_log($selectSQL,"CUSTOM5");

return $selectSQL;

Where the variables are passed to this function from another function

Any suggestions on how i can simply convert the date would be great

Thanks
Seán
Sign In or Register to comment.