Questions tagged [str-to-date]
139 questions
14
votes
1 answer
Why is TFormatSettings not behaving as expected?
I expect the following code to work:
program Project3;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
var
FS: TFormatSettings;
const
DF = 'yyyymmdd';
begin
try
WriteLn(FormatDateTime(DF, Now));
FS :=…

Nick Hodges
- 16,902
- 11
- 68
- 130
5
votes
1 answer
MySQL STR_TO_DATE and timezone
My system timezone is UTC+3.
When I work with timestamp columns in MySQL, they are output for my timezone. So if a timestamp column has 00:00 UTC, it is shown as 03:00 for me.
I need to fill timestamp column with values using STR_TO_DATE.
For…

Mikhail Batcer
- 1,938
- 7
- 37
- 57
4
votes
2 answers
mysql STR_TO_DATE not working
I have a table with a varchar column called birthday
CREATE TABLE IF NOT EXISTS `test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`birthday` varchar(30) COLLATE utf16_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf16…

Thinh Phan
- 95
- 1
- 1
- 8
3
votes
1 answer
Convert a date string with different formatting's and month abbreviation in Dutch using to_date in PySpark
I need to convert a date string to a DateType, but I've several challenges using to_date.
Formatting for day works well (1 or 2 digits), month is a Dutch abbreviation and doesn't work (works only if the abbreviation is equal to English), and year is…

John Doe
- 9,843
- 13
- 42
- 73
3
votes
1 answer
Date format in Informix
Is it possible to print the date in the below format in Informix DB,
May 19 1993 12:00AM ?
Consider the below eg.,
If I shoot the below query,
select sysdate from systables;
It displays as,
2017-12-15 05:00:47.24318
But I want the output to be…

Peter.Fox
- 55
- 1
- 1
- 6
3
votes
2 answers
How to use %U in str_to_date for MySQL
I have a date stored for a weekly metric in a legacy database as a string with this format:
2010 10 which was crafter with the %Y %U format (i.e years followed by week number)
So I try to reverse it into a datetime column by doing …

allan.simon
- 3,886
- 6
- 35
- 60
3
votes
3 answers
MySQL STR_TO_DATE() function returns null
I wanted to convert my date format From MMMM dd,yyyy to yyyy-MM-dd.
I tried using the following:
SET @dt_to = STR_TO_DATE(dateTo, '%d-%m-%Y');
but returns a NULL value.
How will I convert my date to yyyy-MM-dd format in MySQL?
EDITED:
I am creating…

ThEpRoGrAmMiNgNoOb
- 1,256
- 3
- 23
- 46
2
votes
1 answer
How to convert a string date in european format to a valid mysql date format?
I am trying to insert 2 dates through a form in my database, date format in the form is a string like this 01/01/2020 and the field in the database is DATE so I understand it will take YYYY/MM/DD right?
I have trid this query :
INSERT INTO…

jesus fernandez
- 369
- 1
- 12
2
votes
1 answer
STR_TO_DATE with timezone
I my MySQL (version 5.7.25) database there's have a column, which is full of varchar(100) dates like Fri May 04 08:08:42 UTC 2018. I need to convert them to date.
So far I've came up with
SELECT STR_TO_DATE('Fri May 04 08:08:42 UTC 2018', '%a %b %d…

htshame
- 6,599
- 5
- 36
- 56
2
votes
1 answer
spark dataframe column string to date
I would like to convert a spark dataframe string column of 'yyyyMMdd' to date format with spark session (spark) - not spark context.
Since I'm not working with spark context (sc), I cannot use the following code, although it would precisly do what…

C.Tomas
- 451
- 2
- 7
- 15
2
votes
2 answers
Can't create mysql table due to Incorrect datetime value "..." for function str_to_date
The following query works
select date(str_to_date("08-Nov-2005 22:07","%d-%M-%Y %H:%i:%S"))
As expected, it returns
2005-11-08
The following query also works
select date(str_to_date("XXXX","%d-%M-%Y %H:%i:%S"))
As expected, it returns
NULL
I…

kane
- 5,465
- 6
- 44
- 72
2
votes
1 answer
MySQL STR_TO_DATE for strings with just month and year or just year
I have a column called ReleaseDate (which is a string). Most of them are in the form of %e %M %Y (25 May 1979), but there are a few where it is just %M %Y (May 1979) or %Y (1979). Unfortunately, it doesn't seem the STR_TO_DATE works with just %M %Y.…

rjbogz
- 860
- 1
- 15
- 36
2
votes
1 answer
STR_TO_DATE discrepancy between MySQL 5.5 and MySQL 5.6
This SQL returns a DATE in MySQL 5.5 but NULL in MySQL 5.6. Why?
select date(STR_TO_DATE('2015-01', '%Y-%m')) + INTERVAL 1 DAY;
Here's a SQL Fiddle for MySQL 5.5 and 5.6. STR_TO_DATE returns a date in both instances. Converting the result using…

Nice Guy IT
- 97
- 1
- 7
2
votes
3 answers
select data from mysql using two column ranges
I have data like this
sno name date time
1 Irona 2016-01-01 10:00:00
2 Meona 2016-01-02 21:00:00
3 Lessa 2016-01-02 8:00:00
4 Airik 2016-01-03 10:00:00
I m trying query like this
SELECT * FROM `appointment` where…

user3640494
- 61
- 7
2
votes
1 answer
Is there any way to cleanse column having different date formats in mysql
I need to cleanse a column in a table having different date formats.
eg :
%d-%b-%y, %Y-%B-%d, %d/%m/%Y, %d%b%y, %Y-%b-%d, %Y-%m-%d, %d %b %y, %m/%d/%Y
and so on
Now i need to convert all date values to uniform format like **
%Y-%m-%d
**.

MaDHaN MinHo
- 529
- 7
- 23