In MyBatis(mysql) when I select a datetime it returns a LocalDateTime field.
* When the DB value is 2017-11-06 12:00:00 the field value is 2017-11-06T12:00:00
* But when the DB value is 2017-11-06 00:00:00 the field vaule is 2017-11-06T00:00
It is not 2017-11-06T00:00:00 - that is it's getting without 'seconds' in the time.
What could be the reason ?
Im not an expert in MySQL but the answer to this question looks like it might help you.
Related
case#1 -- when inserted the date format (2015-08-01 ) , in mongodb it shows as 2015-08-01T04:00:00.000Z, where i expected it to be 2015-08-01T00:00:00.000Z
case#2 -- when inserted the date format (2016-01-01 ) , in mongodb it shows as 2016-01-01T05:00:00.000Z
where i expected it to be 2016-01-01T00:00:00.000Z
source data type used data stage : Date
target data type specified in mongoDB : Date
Question here is why 04:00:00 timestamp is coming even though source has only YYYY-MM-DD(with out time stamp) ?
can some one help to clarify this ? is this usual behavior of mongodb ? is there any thing i can do to have only timestamp as T00.00.00.000Z at target.
requirement is to not convert the date into string format ..
Is it possible to set value of onl year(without months and days) like 2005, 2001 in Postgresql if data type is Date?
Or should I use other variable types?
How can I set default month/day in postgres?
you can't set a part of a date individually. You could however do something like this:
update the_table
set the_date_column = to_date('2005'||to_char(the_date_column, 'mmdd'), 'yyyymmdd');
You can do something like this:
SELECT to_date('2005','yyyymmdd')
but if you want to store only year than integer is more suitable and preferred.
No, that would cause syntax error:
select date '2014';
-- ERROR: invalid input syntax for type date: "2014"
-- SQL state: 22007
You can use 1st of january in all of your inputs, but if you want to store only the year, integer is more suitable.
I am trying to insert to a timestamp with timezone field of my DB a string which includes date, time and timezone using prepared statement.
The problem is that Timestamp.valueof function does not take into consideration the time zone that the string inludes so it causes an error.
The accepted format is yyyy-[m]m-[d]d hh:mm:ss[.f...] which does not mention timezone.
That is the exact code that causes the error:
pst.setTimestamp(2,Timestamp.valueOf("2012-08-24 14:00:00 +02:00"))
Is there any way that i can overcome it??
Thanks in advance!
The basic problem is that a java.sql.Timestamp does not contain timezone information. I think it is always assumed to be "local timezone".
On solution I can think of is to not use a parameter in a PreparedStatement, but a timezone literal in SQL:
update foo
set ts_col = timestamp with time zone '2012-08-24 14:00:00 +02:00'`;
Another possible solution could be to pass a properly formatted String to a PrepareStatement that uses to_timestamp():
String sql = "update foo set ts_col = to_timestamp(?, 'yyyy-mm-dd hh24:mi:ss')";
PreparedStatement pstmt = connection.prepareStatement(sql);
pstmt.setString(1, "2012-08-24 14:00:00 +02:00");
I believe that you could use one more field in your database, which would include the time zone. And calculate the time manually after you get these two fields
I have a small SQLite3 DB that has an integer field called "dt". It stores date and time.
I am having trouble extracting just the date from the field. However, doing a "select date(dt) from log2" returns nothing. I've tried strftime() as well, but no cigar.
Please help. This is driving me insane.
Thanks.
if the Date in dt is wellformed then the result shoeld be the date from a datetime column
select date('2011-01-01 23:55:55');
should receive
2011-01-01
but
select date('2011-01-01 23:55:5');
would receive nothing
so the dt coloum have to be wellformed
I want to specify a report parameter with Data Type: Date/Time
When I Specify a value manually like 14.07.2011 00:00:00 , the report run as expected but when I "Get a value from a query" ( Stored Procedure returning the date as follows: 14.07.2011 00:00:00 I got the error : The property 'ValidValues' of a report paameter 'Date1' doesn't have the expected type...
Any idea ?
Thanks in advance
I tried against AdventureWorks2008 database.
Data set 1 is from SalesOrderHeader. Data set 2 is Select distinct OrderDate from SalesOrderHeader. I create a parameter OrderDate that has values from Data set 2. Then add Data set 1 with "WHERE OrderDate = #OrderDate". It works for me.
I think as long as your stored procedure returns a DateTime column, you are fine. You may want to check the data type there.
Hope this helps.