Determining whether a string is a date, time, or date and time

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nathan Sokalski

    Determining whether a string is a date, time, or date and time

    When determining whether a String can be converted to a DateTime, you can
    use the IsDate() method. However, I would also like to know whether the
    string is a date, a time, or both a date and a time. Is there any simple way
    to do this without using manual pattern matching? Thanks.
    --
    Nathan Sokalski
    njsokalski@hotm ail.com
    有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。



  • Spam Catcher

    #2
    Re: Determining whether a string is a date, time, or date and time

    "Nathan Sokalski" <njsokalski@hot mail.comwrote in
    news:O8ULZv5jIH A.4376@TK2MSFTN GP04.phx.gbl:
    When determining whether a String can be converted to a DateTime, you
    can use the IsDate() method. However, I would also like to know
    whether the string is a date, a time, or both a date and a time. Is
    there any simple way to do this without using manual pattern matching?
    Thanks.
    Perhaps you can use the Convert.ToDate( ) function? Once you convert it to a
    date, you can check the .Date and .Time properties to determine the
    original values?



    --
    spamhoneypot@ro gers.com (Do not e-mail)

    Comment

    • Nathan Sokalski

      #3
      Re: Determining whether a string is a date, time, or date and time

      This would not work. The reason I need to know this information is so that I
      know whether to include the date, time, or both when submitting the data to
      a database. The reason your suggestion will not work is because a Date
      object ALWAYS has a date and time, even if the date is the default date or
      the time is 0:00 or 12:00 or whatever. Therefore, looking at these parts of
      the Date will tell me nothing about whether a date, time, or both were
      included in the original String.
      --
      Nathan Sokalski
      njsokalski@hotm ail.com
      有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。


      "Spam Catcher" <spamhoneypot@r ogers.comwrote in message
      news:Xns9A6DDD5 D7857Ausenethon eypotrogers@127 .0.0.1...
      "Nathan Sokalski" <njsokalski@hot mail.comwrote in
      news:O8ULZv5jIH A.4376@TK2MSFTN GP04.phx.gbl:
      >
      >When determining whether a String can be converted to a DateTime, you
      >can use the IsDate() method. However, I would also like to know
      >whether the string is a date, a time, or both a date and a time. Is
      >there any simple way to do this without using manual pattern matching?
      >Thanks.
      >
      Perhaps you can use the Convert.ToDate( ) function? Once you convert it to
      a
      date, you can check the .Date and .Time properties to determine the
      original values?
      >
      >
      >
      --
      spamhoneypot@ro gers.com (Do not e-mail)

      Comment

      • Cor Ligthert[MVP]

        #4
        Re: Determining whether a string is a date, time, or date and time

        Nathan,

        Just creating a different box for the date and time string makes things a
        lot easier.
        Especially on a website where this is even more common.

        There are in different cultures two kind of clock registrations used.

        With an 24 hour clock and a 12 hour clock even about this you have to take
        care of.

        Cor

        Comment

        • Patrice

          #5
          Re: Determining whether a string is a date, time, or date and time

          Which DB are you using ? It also has a default time anyway so even if you
          don't include a time part it will have a default time part server side ?

          "Nathan Sokalski" <njsokalski@hot mail.coma écrit dans le message de news:
          %23G7$bA7jIHA.1 204@TK2MSFTNGP0 3.phx.gbl...
          This would not work. The reason I need to know this information is so that
          I know whether to include the date, time, or both when submitting the data
          to a database. The reason your suggestion will not work is because a Date
          object ALWAYS has a date and time, even if the date is the default date or
          the time is 0:00 or 12:00 or whatever. Therefore, looking at these parts
          of the Date will tell me nothing about whether a date, time, or both were
          included in the original String.
          --
          Nathan Sokalski
          njsokalski@hotm ail.com
          有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。

          >
          "Spam Catcher" <spamhoneypot@r ogers.comwrote in message
          news:Xns9A6DDD5 D7857Ausenethon eypotrogers@127 .0.0.1...
          >"Nathan Sokalski" <njsokalski@hot mail.comwrote in
          >news:O8ULZv5jI HA.4376@TK2MSFT NGP04.phx.gbl:
          >>
          >>When determining whether a String can be converted to a DateTime, you
          >>can use the IsDate() method. However, I would also like to know
          >>whether the string is a date, a time, or both a date and a time. Is
          >>there any simple way to do this without using manual pattern matching?
          >>Thanks.
          >>
          >Perhaps you can use the Convert.ToDate( ) function? Once you convert it to
          >a
          >date, you can check the .Date and .Time properties to determine the
          >original values?
          >>
          >>
          >>
          >--
          >spamhoneypot@ro gers.com (Do not e-mail)
          >
          >

          Comment

          Working...