SQLite: Get week number from date

Alejandro Gomez Guerrero

How can I get week number from date, in SQL there is a function: Datepart(GetDate()) and this return the number of week. How can I get this in SQLite?

MikeT

You can use the strftime function with the format string (1st parameter) as %W

as per SQL As Understood By SQLite - Date And Time Functions.

Example

DROP TABLE IF EXISTS getweek;
CREATE TABLE IF NOT EXISTS getweek (mydate TEXT);
INSERT INTO getweek VALUES ('2018-01-01'),('2018-02-01'),('2018-03-01');
SELECT *, strftime('%W',mydate) AS weekofyear FROM getweek;

Which results in :-

enter image description here

Note The date has to be in one of the recognised date/time formats (e.g. 2018/03/01 would result in null as the date is not in recognised format). See the Time Strings section in the link above for the recognised formats.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to get date from week number and day in sql?

分類Dev

How to Get Only Day Name or Number in a Week in JavaScript Date()

分類Dev

Get Last week date range from sunday to saturday moment js

分類Dev

How to get the week number, start date and end date of Compelete year in SQL Server?

分類Dev

Get day number from a specific date

分類Dev

Get whole week date starting from sunday to saturday from given date

分類Dev

Incremental assignment in pandas dataframe to determine month from week number without date element

分類Dev

Get this week's monday's date in Postgres?

分類Dev

Excel - Get Week Day Start Date as formula

分類Dev

How to get which day of week is a specific date?

分類Dev

How to get date range for current week?

分類Dev

SQL Get date of first day of previous week

分類Dev

Get next and last ISO week number in a year

分類Dev

sqlite query to get earliest date

分類Dev

how get the last week start date and end date based on date in current week ruby

分類Dev

Need to find the week number in a calendar quarter of a given date with Javascript

分類Dev

Get range of Week of Year from 0

分類Dev

get day of week as a string for a particular date in Java using Calendar class

分類Dev

Get array of days by week number starting on Mondays in JavaScript

分類Dev

How to get current date time format in SQlite?

分類Dev

Is there a way in python dataframe to populate customise week number from a range of dates?

分類Dev

Match date with day of week?

分類Dev

Get tomorrows date from the webpage

分類Dev

regex to extract number and date from string

分類Dev

Get a number and string from string

分類Dev

Finding week start and week end date

分類Dev

SQLite query to get data from multiple tables

分類Dev

How can I get the right day of the week, if I am setting the date in relation to the given query string parameters?

分類Dev

Get number of records in table during last day and last week with single query in MySQL 5.5

Related 関連記事

  1. 1

    How to get date from week number and day in sql?

  2. 2

    How to Get Only Day Name or Number in a Week in JavaScript Date()

  3. 3

    Get Last week date range from sunday to saturday moment js

  4. 4

    How to get the week number, start date and end date of Compelete year in SQL Server?

  5. 5

    Get day number from a specific date

  6. 6

    Get whole week date starting from sunday to saturday from given date

  7. 7

    Incremental assignment in pandas dataframe to determine month from week number without date element

  8. 8

    Get this week's monday's date in Postgres?

  9. 9

    Excel - Get Week Day Start Date as formula

  10. 10

    How to get which day of week is a specific date?

  11. 11

    How to get date range for current week?

  12. 12

    SQL Get date of first day of previous week

  13. 13

    Get next and last ISO week number in a year

  14. 14

    sqlite query to get earliest date

  15. 15

    how get the last week start date and end date based on date in current week ruby

  16. 16

    Need to find the week number in a calendar quarter of a given date with Javascript

  17. 17

    Get range of Week of Year from 0

  18. 18

    get day of week as a string for a particular date in Java using Calendar class

  19. 19

    Get array of days by week number starting on Mondays in JavaScript

  20. 20

    How to get current date time format in SQlite?

  21. 21

    Is there a way in python dataframe to populate customise week number from a range of dates?

  22. 22

    Match date with day of week?

  23. 23

    Get tomorrows date from the webpage

  24. 24

    regex to extract number and date from string

  25. 25

    Get a number and string from string

  26. 26

    Finding week start and week end date

  27. 27

    SQLite query to get data from multiple tables

  28. 28

    How can I get the right day of the week, if I am setting the date in relation to the given query string parameters?

  29. 29

    Get number of records in table during last day and last week with single query in MySQL 5.5

ホットタグ

アーカイブ