I am brand new to Access.
I believe I am using Access 2000 at work and also using 2003 at home.
I am inporting data from PCEDVR program into excel. Cleaning it up and the transfering into access.
The date data comes in two formats:
short= yymm
med= yymmdd
I have tried changing regional settings. I have looked through the help several times. And have been searching different threads on here for about 2 hours.
What I need to be able to do is import the date data in the military format, keep it in that format , with no seperator, and be able to do queries using the same format ie;
yymmdd= 061111
querie= all between today and + 15 months.
I know I am not speaking program language. I would not want to insult anyone with the feeble attempt. I would really appreciate any help with this. Thank you.
MA1(SW), USN
8 11410 NeoPa 32,556
Expert Mod 16PB
Firstly, it is important to understand that SQL (the query language used for pretty well all queries no matter which provider is used) always uses, exclusively, and without exception, the M/D/Y format when dealing with dates. To repeat myself for clarity, Regional Settings do NOT come into the equation - ever (Why they chose this format above the military format - designed with practicality in mind as well as region independent anyway, is beyond me).
Correction, FIRSTLY it is good to know that you've attempted to find an answer using normal channels before dropping in here with a question.
Moving on...
Clearly, for your purposes, we need to convert one or the other before we can make comparisons.
To convert a date to your format is very straightforward, as there is a built-in and very flexible function (Format()) which does that job for you. In your case - Format([YourDate],'YYMMDD')) or Format([YourDate],'YYYYMMDD'))
I will assume from your question that the military date format uses 2-digit years exclusively (I sometimes use a similar format (but with 4 years) for reasons of practicality).
I have a function (stored in an ordinary 'Module' - not a 'Class Module'.) which can convert your date for you.
This is doctored for your format. - 'YMDToDate takes varDate in YYMM or YYMMDD format and returns it as a date.
-
'If the result is not a valid date it is returned, as modified, but as a string.
-
Public Function YMDToDate(varDate As Variant) As Variant
-
Dim strDMY As String
-
-
strDMY = Mid(varDate, 3, 2) & "/" & Left(varDate, 2)
-
If Len(varDate) = 6 Then strDMY = Right(varDate, 2) & "/" & strDMY
-
If IsDate(strDMY) Then
-
YMDToDate = CDate(strDMY)
-
Else
-
YMDToDate = strDMY
-
End If
-
End Function
It is important to bear in mind when working with converted data, exactly what form the results are in.
Stating the obvious (the bits we often overlook when focusing on a problem) if it's converted to a string it will only respond as one and cannot have date manipulation performed on it (and vice-versa of course).
Good luck with the rest of your project.
NeoPa 32,556
Expert Mod 16PB
CORRECTION:
My code works in England - Doh!
I'm guessing from your signature that that's not your normal field of operations.
Here's a version using native USA format (this is important for the CDate() function) 'M/D/Y'. - 'YMDToDate takes varDate in YYMM or YYMMDD format and returns it as a date.
-
'If the result is not a valid date it is returned, as modified, but as a string.
-
Public Function YMDToDate(varDate As Variant) As Variant
-
Dim strDMY As String
-
-
strDMY = Mid(varDate, 3, 2) & "/" & Left(varDate, 2)
-
If Len(varDate) = 6 Then strDMY = strDMY & "/" & Right(varDate, 2)
-
strDMY = strDMY & "/" & Left(varDate, 2)
-
If IsDate(strDMY) Then
-
YMDToDate = CDate(strDMY)
-
Else
-
YMDToDate = strDMY
-
End If
-
End Function
I did try to edit it but 5 mins after the post it's not an option any more.
PEB 1,418
Expert 1GB
Hi,
Before inserting your data in Access you need to change the format in your dates.
If you can't do it..
Create a table that the field where will be stored the date should be text..
The text in this format will be accepted...
When it's done you need to do from queries -> New query
Add the table with imported information
From query choose Update query
Choose your Column with the date
in the field update to
write down:
Format(CVdate([MYDATE]),"DD/MM/YYYY")
[MYDATE] is your field Name with the respective date
And this is the format that you want..
But before running this query try to change your regional settings of your machine like the format that you have specified...
IF this isn't possible use the codes from NeoPa
Thank you so much for taking the time to assist me on this. I ask of you a little more patience as I admit.... I do not know where to apply the code that is written. I have been looking through the design templates and mirroring fields into my database such as SSN Field format = 000\-00\-0000, but I cannot find anything as advanced as the code you applied for me. Does it go in several areas or is there one spot to apply it.
I am VERY VERY new to all of this. I tried a free online tutorial and learned a little about queries and relationships and such, but it feels like I need an IT degree to create this seemingly basic database. :-(
this is an example of my database...
[name][ssn(primary key/required/indexing/no dups)]active duty service date(yymmdd)][planned rotation date(yymm)][end of active duty obligated service(yymmdd)]
Not written in program language used symbols to indicate [field] and (amplifying information)
I hope this makes sense and I don't sound like too much an idiot, but no this is not my normal line of work. Usually I am either fully armored up with a few weapons providing security in diffeerent parts of the world, or driving a really fast boat with lots of bigger weapons in different parts of the world. As funny as it sounds, that seems so much easier than trying to do this database!!!!!
Thank you all for your time and effort to assist me.
MA1(SW)
[IMG]
CORRECTION:
My code works in England - Doh!
I'm guessing from your signature that that's not your normal field of operations.
Here's a version using native USA format (this is important for the CDate() function) 'M/D/Y'. - 'YMDToDate takes varDate in YYMM or YYMMDD format and returns it as a date.
-
'If the result is not a valid date it is returned, as modified, but as a string.
-
Public Function YMDToDate(varDate As Variant) As Variant
-
Dim strDMY As String
-
-
strDMY = Mid(varDate, 3, 2) & "/" & Left(varDate, 2)
-
If Len(varDate) = 6 Then strDMY = strDMY & "/" & Right(varDate, 2)
-
strDMY = strDMY & "/" & Left(varDate, 2)
-
If IsDate(strDMY) Then
-
YMDToDate = CDate(strDMY)
-
Else
-
YMDToDate = strDMY
-
End If
-
End Function
I did try to edit it but 5 mins after the post it's not an option any more.
PEB 1,418
Expert 1GB
Hi
If you choose to use code so you have to go in modules - > New and Paste the function given by NeoPa there!
Than go in queries use Update query.. maybe here is better to say you how it works...
But for that get the links on the top of the Access forum!
And when the Update query is clear
Paste into "Update to" part under the column with your date Fill the brackets with [The name of your date field]
And run it!
So far so good!
NeoPa 32,556
Expert Mod 16PB
Before inserting your data in Access you need to change the format in your dates.
...
Format(CVdate([MYDATE]),"DD/MM/YYYY")
Be careful PEB.
This is not the way to go.
The format of the dates is necessary for both situations.
Fastboatz must display his dates in military format (yymmdd).
SQL must have its dates passed in SQL format (m/d/y) which is standard across all SQL.
d/m/y - as you've used is restricted to European countries. In USA - outside of the military - they generally use m/d/y. I would guess that it's no co-incidence that this matches exactly the SQL format (the other way around in reality).
Personally, I think they should have used the military format, which is logical and in the best order for sorting.
Correction: Keep confusing military format (yymmdd) with yy/mm/dd (which I feel is best format for SQL standard. Doesn't really matter as they forgot to ask me :(.
BTW Thanks for explaining where (and how) to put the code in - saved me a job.
PEB 1,418
Expert 1GB
Yeap Format() should't work in this case...but not sure....
he he he
See what i've put in my Regional Settings
yyMMdd
And when I paste a dates like this Access accepts them!
So my friend change your Regional Settinfgs to yyMMdd as Date and import your date in Access with simple Copy Paste Don't dream codes, coding, manuals, programmers ... Forget ... No more! Just touch your regional Settings!
I am brand new to Access.
I believe I am using Access 2000 at work and also using 2003 at home.
I am inporting data from PCEDVR program into excel. Cleaning it up and the transfering into access.
The date data comes in two formats:
short= yymm
med= yymmdd
I have tried changing regional settings. I have looked through the help several times. And have been searching different threads on here for about 2 hours.
What I need to be able to do is import the date data in the military format, keep it in that format , with no seperator, and be able to do queries using the same format ie;
yymmdd= 061111
querie= all between today and + 15 months.
I know I am not speaking program language. I would not want to insult anyone with the feeble attempt. I would really appreciate any help with this. Thank you.
MA1(SW), USN
MA1,
IT2 Here.. There is a way that you can enter that data into access, although you will have to go into the design view of the table. You will not be able to use tge date option in data type. If you use number text for the field instead you should be able to make that work.
Now here is a question for you.. Do you or anyone at your command have the instructions on how to install PCEDVR and it's databases??
IT2E
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ben |
last post by:
I would like to use php to query a database and retrieve a unix timestamp.
The problem is that mysql is storing the data in the date format and not
a timestamp.
I am sure that I can amend my...
|
by: Ina Schmitz |
last post by:
Hello all,
I would like to import a comma separated values file to DB2 UDB 8.2.
This file also contains values of type DATE and TIMESTAMP having for example
the following format 900925...
|
by: richardkreidl |
last post by:
How would I check to see if the current time(military format) is
greater then 07:30AM and the day of the week is Monday-Friday.
Pseudo code:
If Current_Time > 07:30AM and Current_Day = Monday...
|
by: Scott |
last post by:
If I have a datetime sql field with afternoon datetime values like below in
DATETIME VALUE, how can I display the time part in ASP as 1:00 PM, instead
of 13:00 PM as seen in CURRENT RESULTS below?...
|
by: cj |
last post by:
Is this the .net way?
Dim msgDate As Date = Now
TextBox1.Text = Format(msgDate, "yyMMdd") 'I want year month day 060306
TextBox2.Text = Format(msgDate, "HHmmss") 'I want 13:23:58
I didn't...
|
by: levinepw |
last post by:
I can convert a yymmdd to (yymmdd - 1 day)
What I do is take the existing yymmdd string, convert it to a
mm/dd/yyyy date and subtract a day from it & then format it back into
yyymmdd.
But the...
|
by: Middletree |
last post by:
I am trying to display dates in a spreadsheet, but the dates need to be in a
format that will allow them to be sorted in Excel. The datatype in the SQL
Server database is datetime. In this case, I...
|
by: pcouas |
last post by:
Hi,
I need to create an XSD file for XML document
In mys XML document i could have various date format
YYYYMMDD, YYMMDD, DDMMYY, DDMMYYYY
I know theses formats before creating xsd file, but i...
|
by: Bill Nguyen |
last post by:
I'm reading a CSV file with the date colum formatted as "YYMMDD" -"070310"
when viewed in notepad or similar trext editor.
However, in my app, using ODBCReader, the column value becomes "70310"...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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
|
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...
|
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...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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...
| |