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

TypeORM createQueryBuilder groupBy FORMAT YYYY-MM-DD #46

Open
codyliou opened this issue Dec 6, 2019 · 2 comments
Open

TypeORM createQueryBuilder groupBy FORMAT YYYY-MM-DD #46

codyliou opened this issue Dec 6, 2019 · 2 comments

Comments

@codyliou
Copy link

codyliou commented Dec 6, 2019

請問TypeORM的createQueryBuilder的groupBy時,可以像MYSQL將date格式用DATE_FORMAT轉為YYYY-MM-DD作為groupBy嗎?

@dzzzzzy
Copy link
Owner

dzzzzzy commented Dec 6, 2019

这个没有试过,group by 里面传的是一个字符串,你可以把DATE_FORMAT函数传进去试试

@codyliou
Copy link
Author

codyliou commented Dec 9, 2019

單純的用select方式會出現Error: 'DATE_FORMAT' is not a recognized built-in function name.

    const test = await this.clickLogRepository.createQueryBuilder('click')
        .select(`DATE_FORMAT(click.createDate,'%Y%m%d')`)
        .getRawMany();
    return test;

參考 http://www.rainsho.cc/blog/0015309585170986b38104a2607421da7884c0705020b66000

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

2 participants