How to show the date and time stored in SQL?

0

I have a small problem, maybe it's the simplest I have a query which shows me date and time that is already stored in BD, but always shows me the same time in all 2018-10-05 12: 46: 03,000 the time if the query is saved well is as follows:

protected function obtenerNotas(Request $request){
        return response()->json(
            DB::table('tblNotas as n')
                ->select('n.idNota','n.Observacion as Nota','n.claveAccion as ClaveAccion','uu.Nombre as Verificador','u.Nombre as Usuario',
                DB::raw("(CONCAT(DAY(Fecha),'/',MONTH(Fecha),'/',YEAR(Fecha),' ',SUBSTRING('2018-10-05 12:46:03.000',CHARINDEX(' ','2018-10-05 12:46:03.000'),9))) AS Fecha"))
                ->join('tblApoyoAcciones as aa','aa.ClaveAccionApoyo','n.claveAccion')
                ->join('tblUsuarios as u','u.idUser','n.idUsuario')
                ->join('tblUsuarios as uu','uu.idUser','n.idUsuario')
                ->where('aa.ClaveAccionApoyo',$request->claveAccion)
                ->orderBy('Fecha','DESC')

                ->get()
        );
    }

Result:

11/30/2018 12:46:03

11/20/2018 12:46:03

11/10/2018 12:46:03

I hope you can help me :( I would appreciate it.

    
asked by R.C. Ana 30.11.2018 в 16:57
source

1 answer

1

I do not understand well the result you want to reach but, try changing what you have inside the raw line you have for this

(CONCAT(DAY(Fecha),'/',MONTH(Fecha),'/',YEAR(Fecha), ' ', Convert(Varchar, Fecha, 108))) As Fecha

or this

(Concat(Convert(Varchar, Fecha, 103), ' ', Convert(Varchar, Fecha, 108))) As Fecha
    
answered by 30.11.2018 в 23:56