Date field behaving different in different environment

Database

Date field behaving different in different environment

Hi,

I have a date column upon casting it shows the result in differnt format in differnt environment.

here is my query.

SELECT DT_END_RANGE AS A ,CAST(DT_END_RANGE AS CHAR(10)) AS B , CAST(CAST(DT_END_RANGE AS CHAR(10)) AS DATE) AS C FROM TAB1 WHERE YR=2014

output in 1 environment:

A    B   C

9/16/2014 14/09/16 9/16/1914 

The same query in differnt environment

output in 2 environment:

A    B   C

9/16/2014 2014-09-16 9/16/2014 

I hope it is environment issue, but let me know how can we fix this ?

Tags (1)
4 REPLIES
Enthusiast

Re: Date field behaving different in different environment

Even if you choose/set as below?

SET SESSION DATEFORM = ANSIDATE

              = INTEGERDATE

Re: Date field behaving different in different environment

Yes , i tried to set session dateform= ANSIDATE and INTEGERDATE

Supporter

Re: Date field behaving different in different environment

which tool do you use to run the query?

you use the same tool for both queries?

run

show your_SQL;

on both environments.

check if the date field contains different format strings in the different environements.

Enthusiast

Re: Date field behaving different in different environment

you can apply format string in date field.

SELECT current_date  AS A ,CAST(cast(current_date as  date format 'dd/mm/yyyy') AS CHAR(10)) AS B , CAST(CAST(current_date  AS CHAR(10)) AS DATE) AS C ;