Skip to content

Commit

Permalink
Fix timestamp_add_interval_months to pass any date (#6815)
Browse files Browse the repository at this point in the history
* fix

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

* use month0

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

---------

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
  • Loading branch information
jayzhan211 authored Jul 1, 2023
1 parent 84832ac commit d526a2e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions datafusion/core/tests/sql/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,8 @@ async fn timestamp_add_interval_months() -> Result<()> {
let t1_naive = chrono::NaiveDateTime::parse_from_str(res1, format).unwrap();
let t2_naive = chrono::NaiveDateTime::parse_from_str(res2, format).unwrap();

let year = t1_naive.year() + (t1_naive.month() as i32 + 17) / 12;
let month = (t1_naive.month() + 17) % 12;
let year = t1_naive.year() + (t1_naive.month0() as i32 + 17) / 12;
let month = (t1_naive.month0() + 17) % 12 + 1;

assert_eq!(
t1_naive.with_year(year).unwrap().with_month(month).unwrap(),
Expand Down

0 comments on commit d526a2e

Please sign in to comment.