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.




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




Red Jungle: we make fantastic software

RSS  Twitter  Facebook  Skype

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. 

 
 
 
 




1371 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 :)

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.




Red Jungle: we make fantastic software

RSS  Twitter  Facebook  Skype

Create new topic



Twitter and LinkedIn »



Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:





News »

Microsoft Translator understands te reo Māori
Posted 22-Nov-2019 08:46


Chorus to launch Hyperfibre service
Posted 18-Nov-2019 15:00


Microsoft launches first Experience Center worldwide for Asia Pacific in Singapore
Posted 13-Nov-2019 13:08


Disney+ comes to LG Smart TVs
Posted 13-Nov-2019 12:55


Spark launches new wireless broadband "Unplan Metro"
Posted 11-Nov-2019 08:19


Malwarebytes overhauls flagship product with new UI, faster engine and lighter footprint
Posted 6-Nov-2019 11:48


CarbonClick launches into Digital Marketplaces
Posted 6-Nov-2019 11:42


Kordia offers Microsoft Azure Peering Service
Posted 6-Nov-2019 11:41


Spark 5G live on Auckland Harbour for Emirates Team New Zealand
Posted 4-Nov-2019 17:30


BNZ and Vodafone partner to boost NZ Tech for SME
Posted 31-Oct-2019 17:14


Nokia 7.2 available in New Zealand
Posted 31-Oct-2019 16:24


2talk launches Microsoft Teams Direct Routing product
Posted 29-Oct-2019 10:35


New Breast Cancer Foundation app puts power in Kiwi women's hands
Posted 25-Oct-2019 16:13


OPPO Reno2 Series lands, alongside hybrid noise-cancelling Wireless Headphones
Posted 24-Oct-2019 15:32


Waikato Data Scientists awarded $13 million from the Government
Posted 24-Oct-2019 15:27



Geekzone Live »

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


Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron



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.

Alternatively, you can receive a daily email with Geekzone updates.