English 中文(简体)
如何从以毫米/d/yyy格式获得一周的一天?
原标题:How to get the day of the week from a date in mm/dd/yyyy format?

我正在使用DB Broswer用于Qite。 我愿检索每个样本本月和本周日的信息。

SELECT Date
FROM Xtrain

returns

Date
26/04/2018
2/4/2018

我已尝试使用Ton-DATE声明。

仅看我是否行使职能:

SELECT TO_DATE( 2022-01-01 , YYYY-MM-DD );

我有以下错误:

Execution finished with errors.
Result: no such function: TO_DATE
At line 1:
SELECT TO_DATE( 2022-01-01 , YYYY-MM-DD );
问题回答

<代码>没有建筑。 TO_DATE function inkouite.

<<>Fixing The Issue

现有日期职能可在上查阅。 https://www.sqlite.org/lang_datefunc.htmlHowever,这些职能预期/需要具体格式的日期(贵国数据没有遵守),见链接重新分类格式。

因此,你需要改革日期,要么利用这些职能,要么按你要求的格式确定日期。 由于它们节省了经费的方式,重新设计工作十分复杂,因为当月和本月,你必须满足单一和双重计算特征。

作为使用<代码>的一个例子CASE WHEN > Construction, the > >youcode) 可以使用诸如:

SELECT
CASE 
    WHEN substr(date,2,1) =  /  AND substr(date,4,1) =  /  THEN  0 ||substr(date,3,1)|| /0 ||substr(date,1,1)|| / ||substr(date,5,4)
    WHEN substr(date,2,1) =  /  AND substr(date,5,1) =  /  THEN substr(date,3,2)|| /0 ||substr(date,1,1)|| / ||substr(date,6,4)
    WHEN substr(date,3,1) =  /  AND substr(date,5,1) =  /  THEN  0 ||substr(date,4,1)|| / ||substr(date,1,2)|| / ||substr(date,6,4)
    ELSE substr(date,4,3)||substr(date,1,2)||substr(date,6,5)
    END
    AS date 
FROM xtrain;

<>Demo

The following show use of the above:-

DROP TABLE IF EXISTS xtrain;
CREATE TABLE IF NOT EXISTS xtrain (date TEXT);
INSERT INTO xtrain VALUES ( 26/4/2018 ),( 2/2/2018 ),( 3/04/2018 ),( 10/04/2018 );
SELECT date AS asis_date,
CASE
    /* handle d/m/yyyy */
    WHEN substr(date,2,1) =  /  AND substr(date,4,1) =  /  THEN  0 ||substr(date,3,1)|| /0 ||substr(date,1,1)|| / ||substr(date,5,4)
    /* handle d/mm/yyyy */
    WHEN substr(date,2,1) =  /  AND substr(date,5,1) =  /  THEN substr(date,3,2)|| /0 ||substr(date,1,1)|| / ||substr(date,6,4)
    /* handle dd/m/yyyy */
    WHEN substr(date,3,1) =  /  AND substr(date,5,1) =  /  THEN  0 ||substr(date,4,1)|| / ||substr(date,1,2)|| / ||substr(date,6,4)
    /* othewise must(should) be dd/mm/yyyy */
    ELSE substr(date,4,3)||substr(date,1,2)||substr(date,6,5)
    END
    AS formatted_date 
FROM xtrain;
DROP TABLE IF EXISTS xtrain;

结果是:

“entergraph

  • 可能有许多办法,上文(仇恨)清楚地说明了所有步骤的细节(可能比替代措施更简练)。

  • www.un.org/Depts/DGACM/index_spanish.htm 真正的解决办法是,以一致的方式,最好是以公认格式之一储存这一日期。 这样,就可以通过日期和时间功能,全面、直接地处理数据。





相关问题
sqlite3 is chopping/cutting/truncating my text columns

I have values being cut off and would like to display the full values. Sqlite3 -column -header locations.dbs " select n.namelist, f.state, t.state from names n left join locations l on l.id = n.id ...

Entity Framework with File-Based Database

I am in the process of developing a desktop application that needs a database. The application is currently targeted to SQL Express 2005 and works wonderfully. However, I m not crazy about having ...

Improve INSERT-per-second performance of SQLite

Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second! Background: We are using SQLite as part of a desktop ...

Metadata for columns in SQLite v2.8 (PHP5)

How can I get metadata / constraints (primary key and "null allowed" in particular) for each column in a SQLite v2.8 table using PHP5 (like mysql_fetch_field for MySql)? sqlite_fetch_column_types (OO:...

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签