Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Comparison of dates

Comparison of dates

Scheduled Pinned Locked Moved Visual Basic
csharpasp-netdatabaseoracle
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vishalmishra
    wrote on last edited by
    #1

    i would like to know how to compare date in ASP.NET Web Application..?? the prob is that we are using Oracle as the database..which uses date as DD/MM/YY format while VB.NET uses MM/DD/YY format,.. so how to cope with these two diff formats ??

    D J 2 Replies Last reply
    0
    • V vishalmishra

      i would like to know how to compare date in ASP.NET Web Application..?? the prob is that we are using Oracle as the database..which uses date as DD/MM/YY format while VB.NET uses MM/DD/YY format,.. so how to cope with these two diff formats ??

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      VB.NET doesn't use any particular date format. The default dateformat is determined by the system, not VB.NET. You should be comparing two Date objects, not two Strings of text representing the dates. Convert your data from the database, as well as the compare date, to Date objects and use the .CompareTo() method of one of them to compare it to the other.

      Dim dt1 As New Date(2005, 2, 12)
      Dim dt2 As New Date(2005, 3, 21)
      Dim result As Integer = dt1.CompareTo(dt2)

      RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      V 1 Reply Last reply
      0
      • D Dave Kreskowiak

        VB.NET doesn't use any particular date format. The default dateformat is determined by the system, not VB.NET. You should be comparing two Date objects, not two Strings of text representing the dates. Convert your data from the database, as well as the compare date, to Date objects and use the .CompareTo() method of one of them to compare it to the other.

        Dim dt1 As New Date(2005, 2, 12)
        Dim dt2 As New Date(2005, 3, 21)
        Dim result As Integer = dt1.CompareTo(dt2)

        RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        V Offline
        V Offline
        vishalmishra
        wrote on last edited by
        #3

        ya Mr. Dave.. the system date that we tried to enter into the Oracle database through "Today.date.date" is not being entered into the database,,.. wat can be the prob... and so how shud we enter the system date in the database ??

        D 1 Reply Last reply
        0
        • V vishalmishra

          ya Mr. Dave.. the system date that we tried to enter into the Oracle database through "Today.date.date" is not being entered into the database,,.. wat can be the prob... and so how shud we enter the system date in the database ??

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Without seeing your code, it's impossible to tell you what your doing wrong. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          1 Reply Last reply
          0
          • V vishalmishra

            i would like to know how to compare date in ASP.NET Web Application..?? the prob is that we are using Oracle as the database..which uses date as DD/MM/YY format while VB.NET uses MM/DD/YY format,.. so how to cope with these two diff formats ??

            J Offline
            J Offline
            jasncab
            wrote on last edited by
            #5

            I run into this all the time in my CIS349 and CIS 405 classes. In fact I just emailed a student of mine about a similar problem. use the oracle to_date or to_char functions. in SQL: select * from orders where orderdate between to_date('01/23/2005', 'MM/DD/YYYY') AND to_date('02/23/2005', 'MM/DD/YYYY') for the reverse.... select to_char(orderdate, 'MM/DD/YYYY') from orders; In the latter version when you get your data back from the db into your data container you will already have it in the right format. http://www.jasncab.com/huberblog :: Jason Huber

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups