Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


jbard

1377 posts

Uber Geek


#70013 16-Oct-2010 14:44
Send private message

Ok so i am making a program in visual basic express 2010, and i have it hooked upto a database made in access 2007.

I run a query on the database like "SELECT * FROM myTable WHERE myDate=#08/10/2010#"

this should work fine as i have checked my database and the dates in their afre in nz date format and their are three rows in the database with this date but my query returns nothing.

So i thought i would change my query to use american dates, so my query is now like this:

"SELECT * FROM myTable WHERE myDate=#10/08/2010#"

and for some strange reason this works even though it shouldn't.

Anyway i thought sweet i will just use american dates and it will be fine - turns out i was wrong, as soon as the date goes over the 12th day it error so when the query is like this:


"SELECT * FROM myTable WHERE myDate=#10/13/2010#"

it has an overloaded date error in visual basic.

I have no idea what i have done wrong here but any help would be fantastic as this has been frustrating me for days.

Cheers

Create new topic
RedJungle
Phil Gale
1108 posts

Uber Geek

Trusted
Red Jungle
Subscriber

  #392613 16-Oct-2010 14:46
Send private message

It's been a loooong time since I've worked with an Access DB.. but try using the format yyyy-mm-dd.



Cadriel
134 posts

Master Geek


  #392616 16-Oct-2010 14:57
Send private message

RedJungle is correct - use the yyyy-mm-dd format. This should cover you off.

Also - it's probably a good idea to make sure the machine running IIS (either your development machine or your server) is setup to use NZ regional settings - as this can cause confusion if not set properly.

So - when you're inserting, or selecting - use the above format and you should be aok. 

jbard

1377 posts

Uber Geek


  #392648 16-Oct-2010 17:40
Send private message

OK cheers thanks very much guys i will give that ago when i got home.

Before i started this project i did check the regional settings and they were set to american for some strange reason.

Thanks again :)



RedJungle
Phil Gale
1108 posts

Uber Geek

Trusted
Red Jungle
Subscriber

  #392652 16-Oct-2010 17:50
Send private message

The other (better) option would be to move towards parameterised queries. So rather than passing in a formatted date string for your query, you would be able to use an actual DateTime object. Much easier, and much safer from a SQL Injection point of view.

Create new topic





News and reviews »

Air New Zealand Starts AI adoption with OpenAI
Posted 24-Jul-2025 16:00


eero Pro 7 Review
Posted 23-Jul-2025 12:07


BeeStation Plus Review
Posted 21-Jul-2025 14:21


eero Unveils New Wi-Fi 7 Products in New Zealand
Posted 21-Jul-2025 00:01


WiZ Introduces HDMI Sync Box and other Light Devices
Posted 20-Jul-2025 17:32


RedShield Enhances DDoS and Bot Attack Protection
Posted 20-Jul-2025 17:26


Seagate Ships 30TB Drives
Posted 17-Jul-2025 11:24


Oclean AirPump A10 Water Flosser Review
Posted 13-Jul-2025 11:05


Samsung Galaxy Z Fold7: Raising the Bar for Smartphones
Posted 10-Jul-2025 02:01


Samsung Galaxy Z Flip7 Brings New Edge-To-Edge FlexWindow
Posted 10-Jul-2025 02:01


Epson Launches New AM-C550Z WorkForce Enterprise printer
Posted 9-Jul-2025 18:22


Samsung Releases Smart Monitor M9
Posted 9-Jul-2025 17:46


Nearly Half of Older Kiwis Still Write their Passwords on Paper
Posted 9-Jul-2025 08:42


D-Link 4G+ Cat6 Wi-Fi 6 DWR-933M Mobile Hotspot Review
Posted 1-Jul-2025 11:34


Oppo A5 Series Launches With New Levels of Durability
Posted 30-Jun-2025 10:15









Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.