2 Replies Latest reply on Oct 2, 2007 11:03 PM by cf_dev2

    sql date time

    KeithLaw999
      hi i have a date time field in ms sql server 2005

      i have 2 form fields i need to insert into the datetime

      i am using CAST(@SchDateTime AS DATETIME) to convert my datetime from

      #DateFormat("#form.SMS_Date# #form.SMS_Time#",'dd/mm/yyyy hh:mm:ss')#

      but the time is not inserting correctly any ideas how i insert 2 form fields into sql ?

      many thanks
        • 1. Re: sql date time
          Level 7
          KeithLaw999 wrote:
          > hi i have a date time field in ms sql server 2005
          >
          > i have 2 form fields i need to insert into the datetime
          >
          > i am using CAST(@SchDateTime AS DATETIME) to convert my datetime from
          >
          > #DateFormat("#form.SMS_Date# #form.SMS_Time#",'dd/mm/yyyy hh:mm:ss')#
          >
          > but the time is not inserting correctly any ideas how i insert 2 form fields
          > into sql ?
          >
          > many thanks
          >

          createodbcdatetime() maybe?

          --

          Azadi Saryev
          Sabai-dee.com
          http://www.sabai-dee.com
          • 2. Re: sql date time
            cf_dev2 Level 1
            KeithLaw999 wrote:
            > the time is not inserting correctly

            What does not correctly mean?

            > #DateFormat("#form.SMS_Date# #form.SMS_Time#",'dd/mm/yyyy hh:mm:ss')#

            DateFormat parses a date value (not a date and time). It uses US date formats. So "12/2/2007" will be considered December 2nd, not February 12th. Also, is your time using a 12-hour or 24-hour clock? It its a 12-hour clock sql server might assume AM, unless you included a time marker (ie AM or PM).

            > am using CAST(@SchDateTime AS DATETIME) to convert my datetime
            Convert() provides more control, but I don't know if dd/mm/yyyy hh:mm:ss is one of the supported styles. An alternative is to use CF to parse the strings into a valid datetime object first, instead of passing a string to sql server and letting it do the parsing.