473,320 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Time zone based on Zip code (not state)

maylortaylor
72 64KB
Ok people, I am here with what i assume to be a simple logic problem.

I'll show you my code first (at least all i think you need) and then explain the problem.

Expand|Select|Wrap|Line Numbers
  1. Function GetTimeZone(ByVal state As String) As Integer
  2.         Dim TaxConnStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ConfigurationManager.AppSettings("Database")
  3.         Dim dbConnection As OleDbConnection = New OleDbConnection(TaxConnStr)
  4.         Try
  5.  
  6.  
  7.  
  8.             Dim queryString As String
  9.             queryString = "SELECT Top 1 Zips.State, Zips.TimeZone "
  10.             queryString += "FROM Zips "
  11.             queryString += "WHERE (((Zips.State)='" & state & "'));"
  12.  
  13.             Dim dbCommand As OleDbCommand = New OleDbCommand
  14.             dbCommand.CommandText = queryString
  15.             dbCommand.Connection = dbConnection
  16.  
  17.             Dim dataAdapter As OleDbDataAdapter = New OleDbDataAdapter
  18.             dataAdapter.SelectCommand = dbCommand
  19.             Dim dataSet As DataSet = New DataSet
  20.             dataAdapter.Fill(dataSet)
  21.             If dataSet.Tables(0).Rows.Count >= 1 Then
  22.                 Return dataSet.Tables(0).Rows(0).Item("TimeZone")
  23.             Else
  24.                 Return 0
  25.             End If
  26.  
  27.         Catch ex As Exception
  28.             Console.WriteLine(ex.Message)
  29.             myLogger.Log(ex.Message)
  30.         Finally
  31.             dbConnection.Close()
  32.         End Try
  33.     End Function
Ok, what i am trying to do is find out the time zone based on not the State (how this code gets it) but by the zip code. This is obviously b/c some states (KY, TN, OK, etc) are divided by their time zone.

So i would ultimately like this function to look at the zip code...find out which time zone that zip code is in...and then return the time zone.

If it's not apparent. The table this information is pulling from is named "Zips". It consists of several columns ranging from zip, city, state, county, areacode, and timezone. The timezone is column in the table only has values such as "5,6,7,8,etc" to correspond to each timezone. 5 = Eastern, 6 = Central, so on..

Thanks for any guidance.
Mar 14 '13 #1
2 2261
Rabbit
12,516 Expert Mod 8TB
I'm not quite sure what your question is. Did you not try changing the field it uses from state to zip?
Mar 14 '13 #2
maylortaylor
72 64KB
Found the answer else where.

Looks pretty straight forward, unless I'm not understanding something. You'd first need to change your method signature to take a zip code:

Expand|Select|Wrap|Line Numbers
  1. Function GetTimeZone(ByVal zipcode As Integer As Integer
Then, you'd have to change your query to search by that zip code:

Expand|Select|Wrap|Line Numbers
  1. queryString = "SELECT Top 1 Zips.TimeZone "
  2. queryString += "FROM Zips "
  3. queryString += "WHERE (((Zips.Zip)=" & zipcode & "));"Everything else should work as is.
  4.  
Mar 22 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Monty | last post by:
Let's say you provide an online service from 7:00AM to 6:00PM Eastern Time (daylight time in the summer). Is there way of showing these hours of availability on a web page in the user's local...
2
by: Jason Priebe | last post by:
I'm a bit confused about SET TIME ZONE and its effect on PostgreSQL's date processing. In my experience with timestamps in all other *nix-based software systems, a timestamp is always a numeric...
0
by: Jason Priebe | last post by:
I posted earlier with a very complex example. This simple one gets to the point much faster. timeofday() seems to behave inconsistently when the timezone is set with "GMT+X" notation. foo=>...
3
by: Jon Davis | last post by:
The date string: "Thu, 17 Jul 2003 12:35:18 PST" The problem: // this fails on PST DateTime myDate = DateTime.Parse("Thu, 17 Jul 2003 12:35:18 PST"); Help? Jon
4
by: brfin999 | last post by:
Server time zone 1 hour different from Client time zone. .Net 1.1 c# Win Forms app: actual date 9/25/04 displays 9/24/04 11:00 PM. When I change client time zone to equal server time zone, date...
0
by: Harold Crump | last post by:
Greetings, I am using SQL Server for state management in an ASP.NET application. The ASPStateTempSessions table is being stored in the ASPState table (and not the SQL Temp database). I am...
5
by: Sehboo | last post by:
We have a c# application (with about 100 forms, and 300+ tables on sql server). We have several customers who use that application but everybody gets the copy of the database. Structure of the...
7
by: Steve | last post by:
Hi All I have a windows application written in VB.net 2005 The users have to select a State of Australia, which I use to check they have the correct windows time zone selected in control panel...
6
by: tatata9999 | last post by:
Hi all, I have this simple time management tool designed and developed. And based on a very thoughtful and kind Frenchman's input I've extended its support to international (support all time...
0
by: =?Utf-8?B?UmljaGFyZCBLaXJieQ==?= | last post by:
Hi, I have W Mobile 2003 SE v 4.21 on my O2 xda IIs PDA. Then I travel to a new time zone I would like to change the time on my PDA but each time it asks if you want to change the appoinment times...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.