CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2004
    Posts
    1,352

    ColeDateTime::GetCurrentDate, ::RemoveHrMinSec??? Need such functions

    Hi Everybody,

    I'm working with COleDateTime Class and I need to do two things:

    1) Get the current date only, with out any Hrs, Min, Sec Value,

    2) Clear the Hrs, Min, Sec of an existing COleDateTime Value.

    Does anyone know how to do that?

    At the time I had to write my own DDX function to strip the hrs, min, sec. I could write a function, but I'm surprised that Microsoft doesn't supply such member functions. ... Maybe there is something I'm missing or an operator out there that I don't know about.

    Any suggestions?
    Rate this post if it helped you.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: ColeDateTime::GetCurrentDate, ::RemoveHrMinSec??? Need such functions

    What's wrong with the GetYear(), GetMonth() and GetDay() member functions.

    COleDateTime has a constructor that takes hours, minutes and sections. You could just set them to zero.

  3. #3
    Join Date
    Jun 2004
    Posts
    1,352

    Re: ColeDateTime::GetCurrentDate, ::RemoveHrMinSec??? Need such functions

    That is precisely the problem, you have to use 3 or 4 functions. I think I mentioned that.

    I want to do it in one step, I have about 10 instancces where I either need the the current year only.

    I need something like COleDateTime::GetCurrentYear(), which would init my Object with only Year,Month,Day info.
    Rate this post if it helped you.

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: ColeDateTime::GetCurrentDate, ::RemoveHrMinSec??? Need such functions

    Quote Originally Posted by ADSOFT View Post
    That is precisely the problem, you have to use 3 or 4 functions. I think I mentioned that.

    I want to do it in one step, I have about 10 instancces where I either need the the current year only.

    I need something like COleDateTime::GetCurrentYear(), which would init my Object with only Year,Month,Day info.
    int nYear = COleDateTime::GetCurrentTime().GetYear();

  5. #5
    Join Date
    Jun 2004
    Posts
    1,352

    Re: ColeDateTime::GetCurrentDate, ::RemoveHrMinSec??? Need such functions

    Quote Originally Posted by GCDEF View Post
    int nYear = COleDateTime::GetCurrentTime().GetYear();
    Thanks, but thiat's not what I ment.

    I ment to say the DATE (YEAR, MONTH, DAY) in one simple step.


    I would need something like ::GetCurrentTime but with out the hr,min, sec and only year, month, day.

    This is the best I could do at the moment. Maybe someone can improve on it??
    Code:
    	::COleDateTime D3;
    
    	D3.ParseDateTime(::COleDateTime::GetCurrentTime().Format(VAR_DATEVALUEONLY),VAR_DATEVALUEONLY );
    
                    
    	AfxMessageBox(D3.Format()); //Check output???
    Rate this post if it helped you.

  6. #6
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: ColeDateTime::GetCurrentDate, ::RemoveHrMinSec??? Need such functions

    Quote Originally Posted by ADSOFT View Post
    ...
    2) Clear the Hrs, Min, Sec of an existing COleDateTime Value.

    Does anyone know how to do that?
    Something like that?
    Code:
    COleDateTime dt = COleDateTime::GetCurrentTime();
    dt.m_dt = floor(dt.m_dt);
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: ColeDateTime::GetCurrentDate, ::RemoveHrMinSec??? Need such functions

    Quote Originally Posted by ADSOFT View Post
    Hi Everybody,

    I'm working with COleDateTime Class and I need to do two things:

    1) Get the current date only, with out any Hrs, Min, Sec Value,

    2) Clear the Hrs, Min, Sec of an existing COleDateTime Value.

    Does anyone know how to do that?
    ...
    Any suggestions?
    I'd just create my own class (maybe derived from COleDateTime) and implement all these features...
    Victor Nijegorodov

  8. #8
    Join Date
    Jun 2004
    Posts
    1,352

    Re: ColeDateTime::GetCurrentDate, ::RemoveHrMinSec??? Need such functions

    Quote Originally Posted by VictorN View Post
    I'd just create my own class (maybe derived from COleDateTime) and implement all these features...
    That's what I figured, too bad there are no member functions provided by the framework for these functions. The do come in handy when you are just working with date values and don't want to do extra programiing to remove time info.
    Rate this post if it helped you.

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: ColeDateTime::GetCurrentDate, ::RemoveHrMinSec??? Need such functions

    It's very hard (if just possible!) to implement the methods for all cases someone could need in the mean time and in the future...
    And I always thought that implement a couple of missed methods yourself is much faster than discuss about such a problem for a long time...
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured