I need to convert DateTime type to Date. here is my code:
DateTime dt = DateTime(2015, 1, 1, 14, 10, 13);
Date z = cast(Date)dt;
Error: cannot cast from DateTime to Date
Whats wrong?
I need to convert DateTime type to Date. here is my code:
DateTime dt = DateTime(2015, 1, 1, 14, 10, 13);
Date z = cast(Date)dt;
Error: cannot cast from DateTime to Date
Whats wrong?
DateTime isn't a Date, you can't cast it. To convert, simply access the DateTime.date()
property:
http://dlang.org/phobos/std_datetime.html#.DateTime.date
const pure nothrow @property @safe Date date();
The date portion of DateTime.