473,395 Members | 1,649 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,395 software developers and data experts.

Date format in access and vb 2008

Hi

The purpose of my system is to calculate the number of motors (stored in a microsoft access table) that is being sent for repair according to the months. This information will then have to be displayed in a form developed in vb2008.

Below are the coding used:

Public Class FormReportMonthlyOverhaul
Dim connstr As String = "Provider= \..\Database.mdb"
Dim rowIndex As Integer = 0

Private Sub FormReportMonthlyOverhaul2_Load(..) Handles Me.Load

Dim sqlJan As String = "SELECT * FROM MotorTable WHERE Start_Date >'" & Format$(2009 / 12 / 31, "dd mm yyyy") & "'AND Start_Date < '" & Format$(2010 / 2 / 1, "dd mm yyyy") & "'"

Dim countJan As Integer
Dim dtJan As New DataTable
Dim daJan As New OleDb.OleDbDataAdapter(sqlJan, connstr)

daJan.Fill(dtJan)
daJan.Dispose()
daJan.Update(dtJan)

countJan = CInt(dtJan.Rows.Count)
lblJan.Text = countJan

End Sub
End Class


The Start_Date column in the MotorTable db is of 'Text' format. I have a feeling that the there's something wrong with the sql. That is why it returns 0 value.

However, i just don't know how to get it done..Really appreciate a helping hand..Thank you in advance!
Oct 3 '10 #1
1 2368
Stewart Ross
2,545 Expert Mod 2GB
Hi. Your main problem is that the start date, as you have mentioned, is not a date at all - it's text. Internally, dates are represented as whole numbers counting up (or down) from a fixed reference point. This is quite different from how they are represented in text form.

As the column in your MotorTable db is not a date but text representing a date you can't use the format function on it (which would otherwise turn a real date into a text representation of the date in whatever format you specify), nor can you use comparators until you can convert what is currently text back into a real date.

If you could post the exact format of your dates as currently stored in the text field we can assist you in converting these to dates so that your comparisons will work correctly.

We'd need to know if the day and month components take up variable space (e.g. d/m/yyyy for values under 10, and dd/mm/yyyy for values of 10 and over). We'd also need to know whether the year is stored as four digits or two.

It would also help to know what the separator characters are - are they slash marks, and are they always used? If not, what character are used to separate days from months from years.

-Stewart
Oct 3 '10 #2

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

Similar topics

10
by: ARC | last post by:
Hello all, General question for back-end database that has numerous date fields where the database will be used in regions that put the month first, and regions that do not. Should I save a...
4
by: gubbachchi | last post by:
Hi, I have an issue regarding the php date format. I choose the date from date-picker which is in the format date('Y-m-d') i.e. 2008-09-12, then I will store this date in the variable $date_id and...
8
by: yashiro | last post by:
Hello i Have a database in SQLserver. I am using php to connect to it and to retrieve data from that database. I have a table with a column (DATATIME) where i do : $result =...
4
by: kuzen | last post by:
Hi When querying data in a table on date, an error is reported stating the data types do not match (error code 3464). The column format is short date, the query considers that and how short date is...
1
by: Yas | last post by:
Hello I've got the following Javascript for a web calendar popup that outputs the date in 4/24/2008 (m/d/yyyy). How can i modify it to output dd/mm/yyyy e.g. 24/04/2008. So all outputs are in...
5
by: Phien-An Nguyen | last post by:
Hello, I have a TextBox1 binds to dateEnterred as datetime. My system date format is m/d/yy. When I gave the value as string, "04/18/2008" to the TextBox1.Text, it changed to "41/8/08". ...
2
chandru8
by: chandru8 | last post by:
Hi to all, I unable to solve this problem. Iam using vb6.0 anb msaccess 2003 Problem: Iam uploading data from various excel.The problem is with the date format only while uploading the date...
3
by: inglesp | last post by:
Hi everyone I've come across some perculiar behaviour in a little database app I'm making with Access. I have a form for users to create a filter for data that goes into a cross-tab query. One...
2
by: pvong | last post by:
Doing this in VB.NET I have a Textbox1 with a date like 8/6/2008. I have a Label1 that I want to show the date as 2008-08-06. Can someone help me convert this?
2
by: Dark223 | last post by:
hi. i'm using a vb calendar to insert a date in a user form, but i can't set the date format to dd/mm/yy . for example: if i use: Text1.Text = Format(Text1.Text, "dd/mm/yyyy")
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.