Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Date format problem.

Date format problem.

Date format problem.


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.

RE: Date format problem.

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.


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

RE: Date format problem.

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)




Alan Edwards

RE: Date format problem.

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

thread183-1240616: Setting a standard DateFormat?

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


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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close