Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date format problem. 1

Status
Not open for further replies.

plcman

Programmer
Feb 17, 2001
92
0
0
GB
Hi

I am using VB6 and an SQl database.

I have a sql statement where I want to select records that occur between two dates picked using the date picker, I have tried formatting the dates using format (date,ddmmyyyy) etc but have had no luck in making my sql work.

I am convinced that is is a formatting problem as if I pick a day that is 12 or below the statement works (incorrectly) but if I pick a day that is over 12 I get the error 'could not create an acceptable cursor'

I am using the where clause:

WHERE start_date BETWEEN dt_from AND dt_too

on the surface all the dates look in the same format (ddmmyyyy) but I have spent all day on this and don't know where to go next.

Any help would be gratefully accepted.
 
Are you using a SQL Server database? If so, you should format your dates in the ISO Unseparated Date Format, which is YYYYMMDD. Do not use slashes, dashes, or dots.

So. Use this format.

Format(Date, "yyyymmdd")

If this works for you, and you'd like to me to explain it, just let me know.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Hi George

I am using SQL Server Express. This seems to becoming a habit you helping me out!!

Of course your solution worked perfectly.

Many many thanks yet again, maybe you should give me your direct line for the next time.(ha ha)

Thankyou

Alan

Regards

Alan Edwards
 
To help you understand why you had the problem in the first place...

thread183-1240616

You really should be using a command object with parameters. This will cure date problems and also apostrophe problems. I understand that it could take a long time to convert an entire application to using command objects, but it doesn't take any time to start using them now. [wink]

I wonder how many people would like to him my direct line... Hmmmm.....

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top