Questions tagged [date-format]

Used for handling non-default style character-strings representing the date and time. This is predicated on handling date and time styles from different nations and/or languages.

Filter by
Sorted by
Tagged with
3 votes
1 answer
269 views

Convert Date format to insert into MySQL database

I'm receiving the date in 'Sun Jun 20 00:40:27 IST 2021' format. Which I need to insert to my MySQL database in datetime(6) format. I used STR_TO_DATE('Sun Jun 20 00:40:27 IST 2021','%d/%m/%Y %T') ...
user avatar
  • 33
-1 votes
1 answer
53 views

How to store date with only four digital format?

In postgresql the date format is yyyy-mm-dd by default. create table sample( quant int,year date); The data file is stored data.csv in csv format such as: quant,year 10,2019 12,2020 13,2021 Try to ...
user avatar
  • 126
-1 votes
1 answer
445 views

Removing leading zeros from month and day

Someone in a PostgreSQL chat room gave me this syntax. It is used in a VIEW that outputs an RSS feed link: to_char(tips_chronic_pain_weekly_selection.start_date, 'YYYY/MM/DD'::text) Example output: ...
user avatar
-1 votes
1 answer
55 views

Is there a Rust crate that implements the SQL date and interval types?

I went looking for a Rust crate (on lib.rs) that implements DateTime and found chrono.rs. However, I have two issues. I cannot find a function that takes a string representing an SQL date and ...
user avatar
0 votes
0 answers
28 views

SQL query to fetch data between 2 date columns from 2 different tables

I am trying to fetch data from two different tables which contain two date columns: ENCODINGDATETIME and CREATEDON. I need those records where days gap between the ENCODINGDATETIME and CREATEDON ...
user avatar
0 votes
2 answers
53 views

Using ISO8601 Dates in Oracle

I’m pretty experienced with other SQLs (PostgreSQL, Microsoft Server, MySQL, SQLite), but not so in Oracle. Is there any way to get Oracle to accept date literals in ISO8601 format. For example: ...
user avatar
  • 2,337
1 vote
1 answer
214 views

Very old date displaying incorrectly when unformatted

At my organization, people have been entering unknown dates as "11/11/1111". When I run a query with the date field, the value shows up as "11/04/1111". However, if I format it as ...
user avatar
0 votes
1 answer
51 views

Given a table with date_time column, how to run a query using only the date

I have a DB with a table which has a column datetime Date_Time. The format of this is for example: 2021-09-01 13:15:16. I would like to set a query that is indipendent of the time but just consider ...
user avatar
1 vote
1 answer
632 views

Calculate days between to dates postgresql

I'm having a problem: I'm trying to calculate days between two dates. Let's say I have the date '2005-05-25 06:04:08' and I want to count how many days are from that day to the current date. I tried ...
user avatar
  • 11
0 votes
1 answer
133 views

What exactly is the datatype input into a DATETIME value in MySQL

I am trying to get data from a PLC directly into a MySQL 8.0 database (using MySQL Workbench). I need to know what data type the input value is for a column set to DATETIME so I can send in the right ...
user avatar
  • 105
0 votes
1 answer
45 views

Better way of handling incorrect date format in a column with "char(10)" data type / TRY_CONVERT equivalent in PLSQL

I have a source table with below structure: create table customer_info (customer_num number, birth_date char(10)) Unfortunately the birth_date column data type is char(10) instead of date. ...
user avatar
  • 1,294
2 votes
2 answers
48 views

Can I change MSSQL interpretation of date order system wide?

I use Laravel with PHP from https://laravel.com/ MSSQL is a driver and works perfectly - with th exception of dates. For some reason the project has decided that the follwoing is a universal date ...
user avatar
-1 votes
2 answers
22 views

casting custom string to date in SQL

I have a column with strings such as 2015-W02, meaning the second week of 2015. I would like to convert it to a date (e.g., corresponding to the Saturday of that week). It does not seem that CONVERT ...
user avatar
0 votes
2 answers
58 views

Can somebody please tell what is the difference between these two date comparisons?

So I have 2 queries as follows: f.DATE >= (GETDATE() - 3) f.DATE >= CAST(CONVERT(VARCHAR(10),GETDATE() - 3,101) AS DATETIME) I think they are the same but the second one gives me more rows ...
user avatar
  • 1
0 votes
1 answer
29 views

to_char(resolved_date-opened_date, 'hh24:mi')

I am using the below to return the hh:mm difference between two date ranges. How would I update this code to minus the hours by 5? CURRENT CODE = to_char(resolved_datetime-opened_datetime, 'hh24:mi') ...
user avatar
  • 5
0 votes
1 answer
669 views

Create table using select statement Truncated incorrect datetime value:

I have looked up different answers on similar question before posting it here. So i have a table with user id and date column I would like to store the results of select query to a temporary table. ...
user avatar
  • 3
1 vote
1 answer
22k views

PostgreSQL: date/time field value out of range

Software: Linux cjz-eshop1-p 5.4.0-33-generic #37-Ubuntu SMP Thu May 21 12:53:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux psql (PostgreSQL) 12.3 (Ubuntu 12.3-1.pgdg18.04+1) I am getting errors due to ...
user avatar
  • 153
2 votes
2 answers
1k views

How to add a day/night indicator to a timestamp column?

There is a timestamp column I use to indicate whether a row was created during day or night time. My code is the following, but for some reason I only get 'DAY' as outcome. Am I not formatting the ...
user avatar
  • 33
0 votes
1 answer
754 views

Postgres - default date format when interpreting strings

What is the default data format that postgres uses when confronted with a character representation of a date? These SQL statements all work, and the character string is always correctly interpreted ...
user avatar
1 vote
2 answers
75 views

Is it safe to use an output (to_char) date format string of more than 22 characters (ORACLE 11)

The ORACLE SQL manual (Page 2-58 of the main 11.1 SQL Manual) states: The total length of a datetime format model cannot exceed 22 characters. However, I've been able to use a format string for ...
user avatar
  • 13
0 votes
1 answer
439 views

ORACLE DB literal does not match format string

I' am having this error: ORA-01861: literal does not match format string 01861. 00000 - "literal does not match format string" *Cause: Literals in the input must be the same length as ...
user avatar
-1 votes
1 answer
365 views

DATEPART YEAR from 'yyyymmdd' Formatted Date

I'm working with a table that stores the date field as 'YYYYMMDD' and I need to filter the query by the YEAR, using the DATEPART from that same date field. WHERE DATEPART(yy,'YYYYMMDD') = 2018
user avatar
0 votes
0 answers
153 views

How to filter date columns in Mysql database effectively?

I have a column called created_at and its datatype is (date). Consider the following two SQL queries. select * from my_table where created_at < '2019-11-05' and the other one is select * from ...
user avatar
2 votes
1 answer
141 views

Unexpected behaviour for to_date() with week number and week day

I tried to convert a date string (year, week, day of week = 'YYYY-WW-D') into a date using the to_date() function. I got these results (demo:db<>fiddle): date string | to_date() -----------------...
user avatar
  • 169
0 votes
1 answer
1k views

MySql date range query not showing all records

I am working on mysql query right now. I write a query from fetch data from march 2018 to march 2019. There are more than 5000 records for this year. I write a query with date range from march 2018 to ...
user avatar
1 vote
2 answers
418 views

Equivalent of Oracle RR date format in SQL Server

Having a bunch of SQL insert scripts generated in Oracle, I have the requirement to adjust them to be usable with T-SQL in Microsoft SQL Server. The Oracle export has date formats like this: to_date(...
user avatar
  • 857
0 votes
1 answer
25 views

Postgresql Date Function Returning Range In Readable Format

I am wondering if it is possible to use postgresql's date-time , concat and case functions to give one of the following results: June 4th to 11th 2019 (where the 1st and 2nd date are within the same ...
user avatar
0 votes
0 answers
222 views

MySQL date_format German date value not change to date type

I have a column that is varchar and the value of the the data is a date (i.e. 31.05.2019) I'm trying to convert the varchar field to a date field using the following function: date_format(...
user avatar
  • 11
0 votes
3 answers
183 views

How to update Different Date formats to one specific datetime formate

I need advise on conversion of date time, below you may see the example data with images for current and expected output Input Table Expected Output
user avatar
  • 1
-1 votes
1 answer
22 views

how do I get date field in certain string format

my table has below columns A: date B: date C: and many more columns, I do not want use to_char(A, date_format), how I can do select * from mytable, and the returned A, B column are in certain ...
user avatar
0 votes
1 answer
59 views

Are iSeries AS/400 (DB2?), Lotus 1-2-3, and Excel date/time formats the same? [closed]

Are the formats for dates/times from AS/400, to Lotus 1-2-3 that carried over into excel...with the date being the number of days since 1900-1-1 when mistaking 1900 for a leap year as an integer, and ...
user avatar
  • 1,652
0 votes
0 answers
51 views

SQL Server group by date, time between status

I have a table that looks like the following: id_usr dt_event Sequence 0000001 2015-08-01 14:57:21.737 1 0000001 2015-08-06 15:34:21.920 2 0000001 ...
user avatar
  • 1
-6 votes
1 answer
78 views

SQL date question [closed]

I'm a novice and need help. Trying to pull data from a table that will return info (various investment trade info) from the previous business day. Is there a command or function for that? thx
user avatar
1 vote
2 answers
2k views

How to cast (a) a date value recorded as a VARCHAR to (b) a specific DATE format for (c) use in an ORDER BY clause

How would I cast a column value (a "non-MySQL" DATE string retained as a VARCHAR) to a "MySQL date" so it can be used for sorting? I have dates in the format of 06-02-2019 (6 feb) but MySQL itself ...
user avatar
  • 123
1 vote
1 answer
259 views

Searching through dates query not working?

I'm trying to query the recent week rows by using dates. BUT the query is not returning any result. It takes forever to execute. I checked my DataBase where date is saved in 1446976737 format which ...
user avatar
  • 43
0 votes
2 answers
1k views

How to format a date field into diferente languages in the same command? (multiple locales)

The following will return the day in Italian: SET lc_time_names = 'it_IT'; select date_format('2018/01/01','%W') as day_italian; However I need to convert or format the date into multiple languages,...
user avatar
  • 13
1 vote
0 answers
87 views

better format using nanodbc R on Windows

Using R-3.5 and odbc (which uses nanodbc), I connect via ODBC and the ODBC Driver 13 for SQL Server ODBC driver on windows 10. DBI::dbGetQuery(odbccon, "select SYSDATETIMEOFFSET() as now") # ...
user avatar
  • 121
-1 votes
2 answers
575 views

TSQL Query to Remove Dates in Multiple Formats from Text Values [closed]

I have a table with list of text values that contain dates in any format types. I need a TSQL query to remove the dates from each row in the table. The date samples are below. What is the best way ...
user avatar
  • 493
5 votes
1 answer
864 views

Getting year DATEPART from Unix date

In my database, the dates are retained as days elapsed since/before 01/01/1970, which I understand to be a Unix date format, eg. today is 23rd May 2018 and the value is 17674. I'm trying to run a ...
user avatar
  • 53
1 vote
0 answers
2k views

PostgreSQL datestyle / OS locale issue

The problem of this issue has been identified and can be treated as resolved. (see the comments bellow) I try to install a web-application on a server (debian) and on a local machine (ubuntu). When ...
user avatar
  • 121
1 vote
1 answer
10k views

Incorrect value for str_to_date

I'm running a simple procedure that reads from a VARCHAR column and inserts data into a TIME column, using this format: STR_TO_DATE(vTestTime, '%H:%i'). I'm getting the error SQL Error (1411): ...
user avatar
1 vote
0 answers
2k views

MySQL 5.6 - ERROR 1292 (22007): Incorrect datetime value: '2015-03-29 01:01:12'

I am trying to copy logs from one of my MySQL 5.6 databases to another. Unfortunately, it keeps failing when it tries to insert one of the times with the following error message: ERROR 1292 (22007): ...
user avatar
1 vote
1 answer
1k views

Formatting Timestamp in Default Constraint

Can you format a TIMESTAMP WITH TIME ZONE column in a CREATE TABLE default constraint in Postgres v10.x? Example Code: create_date TIMESTAMP WITH TIME ZONE DEFAULT to_char(current_timestamp, 'DD-...
user avatar
1 vote
1 answer
7k views

Why does JSONB show a different date format than Javascript?

With Javascript's .toISOString(); and .toJSON() I get (new Date()).toISOString(); 2018-01-30T12:04:13.153Z Using PostgreSQL when I return a date, I get # SELECT to_jsonb('2018-01-30T12:04:13.153Z'::...
user avatar
1 vote
1 answer
4k views

MySQL : DATE_FORMAT() vs. SUBSTR()

I'm currently working on MYSQL DB optimizations. I'm looking around some slow queries and I try to optimize some of them. In my app, for statistics purposes, I'm querying and -very- big table (...
user avatar
  • 15
4 votes
1 answer
3k views

Parsing COPY's binary format to access a tsrange

How is tsrange stored in binary? For example create table CREATE TABLE public.test (t tsrange); INSERT INTO test VALUES ('[2010-01-01 14:30, 2010-01-01 15:30)'); INSERT INTO test VALUES ('[2011-01-...
user avatar
  • 143
3 votes
3 answers
3k views

Get all CONVERT(datetime) styles (formats)

I know this is kinda stupid to ask but is there a Transact-SQL function or anything that returns all CONVERT(datetime) styles (formats)? Something like fnDateFormats will return all date formats: ...
user avatar
0 votes
0 answers
134 views

SQL Server 2014 datetime conversion

I have a date formatted as follows: 00:50:34 Jun 25, 2017 PDT .. actually I have it in this format 00%3A50%3A34+Jun+25%2C+2017+PDT but can easily transform in the above. I was wondering if there'...
user avatar
  • 349
0 votes
1 answer
2k views

Microsoft SQL Server 2008+ TIMESTAMP problem

I'm currently facing a Problem, where the SQL Server refuses my Timestamps. I am accessing the Server via EclipseLink (Java) but this shall not be the problem, as i can test the queries on the Server ...
user avatar
  • 425
2 votes
1 answer
187 views

International Components for Unicode (ICU) Date Formatter for MySQL?

Regarding to ICU - International Components for Unicode definition: ICU is a mature, widely used set of C/C++ and Java libraries providing Unicode and Globalization support for software ...
user avatar
  • 21