1

I have a int variable containing value eg. 31012015 but I tried to cast to date format eg to dd-mm-yyyy. Part of my query is:

select * from dblink(
  'dbname=dbexample port=5432 host=127.0.0.1 user=postgres password=root', 
  'select * from tableexample where fconclusion between 2014-01-02 and 2014-12-31')
as k(
  id_principal integer, 
  nestrategia smallint, 
  ctitulo character varying(300), 
  factivacion date, 
  nestado smallint,
  fcreacion timestamp without time zone, 
  id_usuario integer, 
  nstatus smallint, 
  nmunicipio smallint, 
  nactividad smallint,
  fconclusion date, 
  id_personal integer, 
  nactivo smallint, 
  fmodificacion date, 
  nconclusion smallint
)

PgAdmin show the next error:

ERROR: operator does not exist: date> = integer HINT: No operator matches the name and type of arguments. You may need to add explicit type conversions. CONTEXT: Error Occurred on dblink connection named "unnamed": could not execute query.

Can someone help me?

Codler
  • 10,951
  • 6
  • 52
  • 65

1 Answers1

0

Try DateTime::createFromFormat():

$dt = DateTime::createFromFormat('dmY', $int);
echo $dt->format('d-m-Y');

demo

Glavić
  • 42,781
  • 13
  • 77
  • 107