• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

sql date time

New Here ,
Oct 02, 2007 Oct 02, 2007

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

437

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 02, 2007 Oct 02, 2007

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 02, 2007 Oct 02, 2007

Copy link to clipboard

Copied

LATEST
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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation