Go Back   Cyber Tech Help Support Forums > Software > Web Development & Graphic Design

Notices

Reply
 
Topic Tools
  #1  
Old February 22nd, 2007, 10:31 AM
sheldondsouza's Avatar
sheldondsouza sheldondsouza is offline
Senior Member
 
Join Date: Jul 2006
O/S: Windows XP Pro
Location: Sharjah, UAE
Age: 23
Posts: 411
Exclamation Compare Date IN VB6 Using SQL Query

Have been creating this application and is almost done but ran into a problem

In the database the table Attendance has a field Date and its in the format text, so what i am doing basically is comparing the two dates one date is displayed in the form as "MM/DD/YYYY" or eg 02/15/2007

so when comparing this one with the one in the databse using the code below, i populate the grid and works fine.

sql3000 = "select * from Attendance where TherapistName like '" & (Combo4.Text) & "%' And Date = '" & (Text18.Text) & "' Order by Attendance_Id "

_____________

However when creating reports it was mandatory for me to change the date field in the database from text to date/time and the date previously in the field changed form 02/15/2007 to 2/15/2007

Since the field was change, i change the sql query to as it gave and error i removed the single quotes as the field was not text

sql3000 = "select * from Attendance where TherapistName like '" & (Combo4.Text) & "%' And Date = " & (Text18.Text) & " Order by Attendance_Id "

but nothing works! i thought propbaly in the form the textbox is shown as 02/15/2007 and is not same in database format so changed the way the text was shown in the form and tried comparing but still no use!

It works fine when its text , but i need it using date/time format

Please help project is stuck here i need to complete this as soon as possible
__________________
Lose The Entourage !
Reply With Quote
  #2  
Old February 22nd, 2007, 12:55 PM
oracle128's Avatar
oracle128 oracle128 is offline
Α Ω
 
Join Date: Oct 2000
O/S: Windows XP Pro
Location: Melbourne, Australia
Age: 24
Posts: 9,401
What database server are you using?

Usually, date fields should be referred to with surround single quotes (hashes in Access), and using the format 'YYYY-MM-DD' is the safest.
__________________
Oracle's backup tutorial

"A lot of people say games are addictive. Well, they're addictive in the sense that anything you like doing you repeat endlessly. But no one would say, 'Mr Kasparov, you have a chess problem,' or 'Tiger Woods, you have a golf addiction.'" - Ian Livingstone, Creative Director, Eidos.

"A problem well stated is a problem half solved" - Charles Franklin Kettering
Reply With Quote
  #3  
Old February 22nd, 2007, 02:17 PM
degsy's Avatar
degsy degsy is offline
Cyber Tech Help Moderator
 
Join Date: Jul 2001
Location: North-East, UK
Posts: 22,023
Blog Entries: 1
In Access you can use Format() to get the datetime in a format of your choice.
In SQL Server you can use Convert or Cast.
__________________
Cheers,
Degs

Please post back with your results
CTH Terms of Use

CTH Subscriptions :: Adaware Guide :: HijackThis
Reply With Quote
  #4  
Old February 23rd, 2007, 12:10 PM
sheldondsouza's Avatar
sheldondsouza sheldondsouza is offline
Senior Member
 
Join Date: Jul 2006
O/S: Windows XP Pro
Location: Sharjah, UAE
Age: 23
Posts: 411
Never mind, i just made the date the primary key and any duplicate entires will give a message box stating that entry for today is done
__________________
Lose The Entourage !
Reply With Quote
Reply

Bookmarks

Topic Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:03 AM.

[ RSS ]