From ea418c7fbcd54d7222583914477d087fe7d6c5e8 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 22 Feb 2009 22:13:22 -0400 Subject: [PATCH] Allow date and datetime values to inter-convert --- src/value.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/value.cc b/src/value.cc index d39597bd..54a6038f 100644 --- a/src/value.cc +++ b/src/value.cc @@ -907,6 +907,9 @@ void value_t::in_place_cast(type_t cast_type) case DATE: switch (cast_type) { + case DATETIME: + set_datetime(datetime_t(as_date(), time_duration(0, 0, 0, 0))); + return; case STRING: set_string(format_date(as_date(), string("%Y-%m-%d"))); return; @@ -916,6 +919,9 @@ void value_t::in_place_cast(type_t cast_type) break; case DATETIME: switch (cast_type) { + case DATE: + set_date(as_datetime().date()); + return; case STRING: set_string(format_datetime(as_datetime(), string("%Y-%m-%d %H:%M:%S"))); return;