Float to datetime or timestamp SSIS - ssis

does anyone know how to convert float to datetime or timestamp in SSIS? Please
Example, float = 0,25; time = 06:00:00
(DT_DBTIMESTAMP)[column float]

Related

Datetime 0000-00-00 00:00:00 using CURRENT_TIMESTAMP

I'm running xampp 3.3.0, mysql 8.0. In my database, there is a column datetime with type "datetime". I'm trying to insert data in it with CURRENT_TIMESTAP.
Example of query:
INSERT INTO `statistics` (`chat_id`, `user_id`, `message_id`, `datetime`, `ai_unique`) VALUES ('988', '767', '98765', 'CURRENT_TIMESTAMP', NULL);
It inserts, but I'm getting
Warning: #1265 Data truncated for column 'datetime' at row 1
And instead of current timestamp, it inserts 0000-00-00 00:00:00
Some time ago it worked just fine, but now it's inserting 0000-00-00 00:00:00. If I manually write a date here like 2023-01-11 22:52:01 it works just fine
'CURRENT_TIMESTAMP' (with single-quotes) is a string. It doesn't have a datetime value. MySQL makes an effort to convert the string to a datetime, just as it would convert the string '2023-01-24 13:09:00' to a datetime. But the string you used cannot be converted in this way.
CURRENT_TIMESTAMP (a pseudoclumn with no single-quotes) has a datetime value.
CURRENT_TIMESTAMP() (a function) also returns a datetime value.

Error Code: 1292 Truncated incorrect datetime value

insert into test_date
select
shopify_update
from `vw_shopify_json_price`
where cache_id=669
Error Code: 1292
Truncated incorrect datetime value: '2019-05-17T11:34:30-04:00'
CREATE TABLE `test_date` (
`t` datetime DEFAULT NULL
)
datetime does not allow a timezone or timezone offset. Some reasonable choices:
convert the timestamp to UTC and store that (my recommendation)
convert the timestamp to the timezone of your database and store that
I had a similar issue, which was caused by the date time field being stored as varchar.
The issue was resolved by doing this:
1) Taking first 10 characters of the timestamp
2) Converting it to date.
where str_to_date(left(my_future_date,10), '%Y-%m-%d') > now()
P.S. this is a hacky way, but i did not want to go through all the code related to this field, and doing all the changes. This solved my issue in 30 seconds. But solution took half an hour to find.

How to create empty datetime format in mysql

The mysql default datetime format when null is 1970-01-01 07:00:00
Is it possible to have an empty string (" ") instead of a null when loading it into a data grid? It would behave as an empty column/cell.

MySQL datetime vs timestamp and highcharts

I have been using highcharts for datetime-based charts and it needs a timestamp to make the chart.
In my DB I have a DATETIME column and I convert to timestamp when I do the select:
SELECT UNIX_TIMESTAMP(CONVERT_TZ(`datetime`, '+00:00', ##session.time_zone)) * 1000 AS datetime
I have a lot of rows and I think that select may be slow. Should I store the dates as timestamp instead of datetime?

MySQL NOW() Returns Only Year

MySQL docs about NOW() function...
Returns the current date and time as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS.uuuuuu format, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone.
Here's my query...
$sql = "
INSERT INTO `users` ( `username`, `password`, `email`, `time` )
VALUES ('{$username}', '" . sha1( $password ) . "', '{$email}', NOW() )
";
The problem is that in the database I don't have the full datetime, but only the year. Any solutions?
It's int(10) like it was when I used UNIX timestamp.
NOW() works for DATETIME fields only.
You need to either convert your field to DATETIME (the preferable method), or convert NOW() into a UNIX timestamp using UNIX_TIMESTAMP():
UNIX_TIMESTAMP(NOW())
I had this same trouble and was stumped for the longest time till I read this question. I used mysql's now() function to update a member's last login time.
MySQL's now() returns the date time as a string, like YYYY-MM-DD HH:MM:SS - somewhere along the line I stopped using this and started using time() (UNIXTIME) (makes it easier to work with) which returns a string of numbers, like 1352254528. But you can't store a string of numbers like this in a datetime field, and likewise, you can't store YYYY-MM-DD HH:MM:SS in an int(11) field. The latter will result in only the year being stored.
In the end you should use:
int(11) if you're going to use PHP's time() function to store the time as a string of numbers
or
DATETIME field if you're going to use MySQL's NOW() function.
try
strtotime(now())
And you should definitely use timestamp or datetime as a type for your column.