Sort on a numeric month value in a server side script and also use date field as format date.

Sort on a numeric month value in a server side script and also use date field as format date.

bbrindzabbrindza Posts: 316Questions: 73Answers: 1

My SSP has a date field which I need to not only sort ( either server side or front-end) but also format.
Not sure if I have to pull out the numeric month as a separate variable and sort that and use my HRDTNR fieldvfor the formatted date.

Here is my current script sans the numeric month. The filed in question is HRDTNR , "DATE NEXT REVIEW "

<?php

// DataTables PHP library
require( $_SERVER['DOCUMENT_ROOT']."/DataTables_Editor/php/DataTables.php" );
 
// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate;
 
// Build our Editor instance and process the data coming from _POST
//Editor::inst( $db, 'NWFF.PAYEMPDE','EMP' )
//Editor::inst( $db, 'BOBBRI.INVENTOR','INITEM' )
Editor::inst( $db, 'NWFF.PAYEHRLY', 'HREMPN')
->debug(true)
    ->fields(
     // Field::inst( 'name' )->validator( 'Validate::notEmpty' ),
        Field::inst('HREMPN') -> set(false),    // Used to disable editing to key field
        Field::inst('HRLOC'),                   // LOCATION I.D.             
        Field::inst('HRFNAM'),                  // EMP FIRST NAME & INITIAL  
        Field::inst('HRLNAM'),                  // EMPLOYEE LAST NAME        
        Field::inst('HRDEPT') ,                  // DEPARTMENT                
        Field::inst('HRYRSL'),                  // YEARLY SALARY             
      
  Field::inst( 'HRDTNR' )  // DATE NEXT REVIEW  
        ->validator( 'Validate::dateFormat', array(
            'format' => 'Ymd'
        ) )
          ->getFormatter( 'Format::datetime', array(
              'from' => 'Ymd',
              'to' =>   'F'
          ) )
    )
    ->process( $_POST )
    ->json();

This question has an accepted answers - jump to answer

Answers

  • bbrindzabbrindza Posts: 316Questions: 73Answers: 1
    Answer ✓

    Please close or remove

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    For anyone else that finds this thread, could you say how you resolved it?

    Thanks,
    Allan

This discussion has been closed.