How can I convert the Date format for column in sqlite table?

user121

In sqlite, my table is as follows:

---------------------
Date           Temp
---------------------
201309010051    82
201309010151    81
201309010251    80
---------------------

For the 'Date column, it is currently in the following datetime format: YYYYMMDDHHMM.

I want to change this format of the entire date column, for example from : 201309010051 to :
2013-09-01 00:51

This is what I have tried so far:

select substr(Date, 7, 4)||"-"||substr(Date, 1,2)||"-"||substr(Date, 4,2) from myTable

An example of the incorrect/garbage output for the first row (i.e., 201309010051) is:

0100-20-30

How can achieve the desired format conversion?

Tedo G.

You are using substr() function incorrectly. try this way:

select substr(Date, 1, 4)||"-"||substr(Date, 5, 2)||"-"||substr(Date, 7, 2) 
||" "||substr(Date, 9, 2)||":"||substr(Date, 11, 2)  
from myTable

also here is the substr manual: https://www.techonthenet.com/sqlite/functions/substr.php

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I convert a date into another format with moment.js?

How can I export to sqlite (or another format) and retain the date datatype?

How can I convert a custom `dayHour` string variable to date format?

How can I convert the values in one column into headers of a new table?

How can I load a snowflake table using Pyspark and the date column of my Dataframe should reflect as TIMESTAMP_LTZ format

How to convert this whole column into date format?

How can I convert a date in YYYYMMDDHHMMSS format to epoch or unix time?

How can I convert "/Date(1399739515000)/" into date format in JavaScript?

How can I convert timestamps in a column to a date?

How can I convert this query result to date format (SQL Server)

How can I convert a date format to another date format in Swift?

How can I convert multidimensional object to table row column format in javascript

how can I update SQLite table with new column?

How to convert a binary date column date into gregorian date format in sql

how do i convert data table date to a certain string format

How can I set a default value of 0 to a SQLite table column?

How can I convert get date to format of yyyymmdd?

How to convert date Column from "Month Year " (Ex. March 2018) to ISO format in SQLite?

How can I convert a column of Excel into a specific dictionary format?

How can i set current date, as a database table name in sqlite?

How can I traverse a particular td column in an html table and replace the innerText to change the date format?

How can I convert this date-format in a format accepted by lubridate?

How do I convert a column of dates in integer format to date format in base R?

How can give date format dd/mm/yyyy for the date column of an html table

JavaScript How Can I convert this innerText to a valid date format?

How can I convert a date format in SQL?

How i can convert chr column into date in R?

How can I convert a table column to a row?

How can I convert a specific string format to date or datetime in Spark?