Solved

Inserting and modifying dates on SQLSERVER 7.0 ( danish format )

Posted on 2002-04-07
8
165 Views
Last Modified: 2013-12-24
Hi,

The case is :

I use SLQ Server 7.0 as database for my application and I'm trying to insert dates passes from a form into a datetime field in a table. However EVERYTIME I do so the dates get completely 'f..... up'. I've tried almost everything, ex. CreateODBCDate, Dateformat LSDateformat functions etc.

THE DATEFORMAT has to be dd-mm-yyy ( DANISH STYLE )

I think it maby has something to do with the Database settings...does anyone know how to set this up ?

/Kenneth
0
Comment
Question by:kennethlowe
8 Comments
 

Author Comment

by:kennethlowe
ID: 6923854
Well, I found a solution to the problem myself on the Macromedia Website...hope other can use it :

http://webforums.macromedia.com/coldfusion/messageview.cfm?catid=6&threadid=302059&highlight_key=y&keyword1=insert%20date

/Kenneth
0
 

Expert Comment

by:manonng
ID: 6927884
Hi

I think you have set your sql's dateformat as GB or US,
Use 'set dateformat dmy', more details in sql help file.

manon
 
0
 
LVL 6

Expert Comment

by:reitzen
ID: 6928970
I feel your pain, my brotha!  I had the same frustrating experience.  Here's what I came up with.

Since CF passes everything as a string; pass it to the stored procedure as a string. Then convert it to your date type before inserting it.

The variable that is going to accept my date/time value is:
        @event_date     varchar(50)

After the first BEGIN I declare my date/time variable and then convert the varchar to the date/time data type:
        declare @ConvertDate datetime
        select  @ConvertDate = Convert(datetime, @event_date)

Then, simply insert/update your date/time field using the converted @ConvertDate variable.

If you are not using stored procedures, I have had pretty good luck by simply surrounding my CF date/time variable with single quotes:
        myDateTimeField = '#Variables.dDateTime#'

HTH
Rob
0
 
LVL 1

Expert Comment

by:dawesi
ID: 6939507
I'm also in your boat, using Australian dates...grrr..

I resorted to formatting the dates in literal format and dumping them into the ODBCDateTime('1 Jan 2002') function.

or you can use this sort of thing (If it works on your server)

<CFSet temp = SetLocale("English (Australian)")>
<CFSet Date2 = CreateODBCDateTime(LSDateFormat(Date,'dd/mm/yy'))>
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Expert Comment

by:dawesi
ID: 6939509
PS:
Australia Style for dates dd/mm/yyyy
locale = English (Australian)

German Style for dates dd-mm-yyyy
locale = German (Standard)
0
 
LVL 17

Expert Comment

by:anandkp
ID: 7176390
Hi there,

<cfset countjan="#ListValueCount(testlist,'01','/,')#">

u can "n" delimeters for a list & in ur case :

use 2 delimeters to get the desired output - it surely would give u the right answere.

also enclose '01' in single quote !!!

let me know

K'Rgds
Anand
0
 
LVL 17

Expert Comment

by:anandkp
ID: 7176394
Hi,

SORRY ABT THIS - it wasnt meant for U !!!

pls reject it !!!

SORRY ONCE AGAIN !!!

Anand
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8300770
PAQ'd and points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Join & Write a Comment

Suggested Solutions

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now