Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to parse format specifier %u: Unrecognized format for strftime/strptime: %u #244

Open
ctsrc opened this issue Dec 24, 2023 · 0 comments

Comments

@ctsrc
Copy link

ctsrc commented Dec 24, 2023

According to https://duckdb.org/docs/sql/functions/dateformat#format-specifiers

Specifier Description Example
%u ISO 8601 weekday as a decimal number where 1 is Monday. 1, 2, …, 7
%w Weekday as a decimal number. 0, 1, …, 6

But I try to do the following in my code:

let query =
        r"select
            make_timestamptz(id * 1000000) as ts,
            strftime(ts, '%H:%M') as s_hm,
            strftime(ts, '%z') as s_z,
            strftime(ts, '%u') as s_wd,
            id,
            v0,
            c0
          from points
          where s_hm = '12:00' and s_wd = '7'
          order by id desc
          limit 144";
    let mut stmt = db_conn.prepare(&query)?;
    let points_iter = stmt.query_map([], |row| {
        Ok(PointRowSelectSubsetExtraPlus {
            hm: row.get(1)?,
            z: row.get(2)?,
            wd: row.get(3)?,
            id: row.get(4)?,
            v0: row.get(5)?,
            c0: row.get(6)?,
        })
    })?;

And I get this error message:

Error: Invalid Input Error: Failed to parse format specifier %u: Unrecognized format for strftime/strptime: %u

Caused by:
    Error code 1: Unknown error code

Whereas using %w works. But I would like to use %u.

Platform is macOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant