Results 1 to 4 of 4

Thread: [RESOLVED] Compare two dates

  1. #1

    Thread Starter
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Resolved [RESOLVED] Compare two dates

    hi guys! is there any way for me to compare two dates exlcuding the seconds? DD/MM/YYYY HH:MM

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Compare two dates

    Use DateTime.Compare()

    When passing it the datetimes to compare, set the seconds to 00. Another way would be to create two new datetime variables by extracting the year, month, day, hour and minute from the originals and comparing them.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Compare two dates

    I'd go with mendhak's first suggestion. To get a Date object equivalent to another Date object less the seconds use:
    VB Code:
    1. myDate.AddSeconds(-myDate.Seconds)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Re: Compare two dates

    Thanks guyz!

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