Last active
December 29, 2020 18:23
-
-
Save Jtosbornex/f2153cf8822ec5e910b729b51cafec33 to your computer and use it in GitHub Desktop.
Typeorm Date Comparisons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { FindOperator, LessThan, MoreThan } from "typeorm" | |
import moment, { Moment, MomentInput } from 'moment'; | |
export const MoreThanDate = (date:MomentInput) => MoreThan( | |
new FindOperator( | |
'moreThan', | |
moment(date).format( 'YYYY-MM-DD HH:mm:ss' ), | |
) | |
); | |
export const LessThanDate = (date:MomentInput) => LessThan( | |
new FindOperator( | |
'lessThan', | |
moment(date).format( 'YYYY-MM-DD HH:mm:ss' ), | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For some reason LessThan and MoreThan don't work as expected for date values. This works great for me.