Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




Storing Dates In The Billions Of Years


Since the datetime format only allows dates between 1000-9999 I won't be able to use this directly. I am considering using perhaps an integer or some sort of a date hack.

Right now I am considering all options. One I came up with is storing an alternate number to be stored alongside which would designate the date's power. So '0' would mean the date is between 1000-9999, '1' would mean the date is between 8000BC-999... etc. I am wondering if this would be too much of a problem coming up with queries, however, so right now I am leaning towards a regular year integer and perhaps a secondary integer for the MMDD.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
SQL For Finding Years In Dates?
What I need is a SQL statement that can find what years are in the
database that is greater than last year.

For example...

I have a table full of dates ranging from 2001 to 2005..

I am straining my brain to figure out a SQL statement that can give me
a list of years greater than last year..

In this case I need a list that has..

2003
2004
2005

Storing Dates
I'm currently in the process of migrating from MS Access to MySQL. In my MS Access database the dates are stored in the format MM/DD/YYYY. However on MySQL it seems to want the format YYYY/MM/DD. Therefore the dates aren't being stored properly when I'm importing data into my MySQL database, they are just being displayed as 0000-00-00. Is there a way I can change the format the dates are saved in MySQL?

Storing Dates
i'm currently working on a small php program to store details of petrol receipts.
The part i'm stuck on is which field type to use to store the date. And then how to order the dates.
i need to order by year then month and then day. I have no idea how to sort dates and need to be able to add receipts in any order.

*edit*
the date i want to store is in the format DD.MM.YYYY
the date is created via pull down menu's

Storing Dates In Mysql
Is there a way I can change the way dates are stored in the mysql database from YYYY-DD-MM to DD-MM-YYYY?



Storing Partial Dates
I am creating my first mySQL database to store genealogy information and
would like fields for date of birth and date of death.Unfortunately some older records are quite vague with only the year being
available in some cases. I am concerned that if I store only the year or
month & year where available then when the information is retrieved then
the missing information will be defaults which are incorrect.
For example if I store the date of birth as "March 1900" how can I avoid
this being retrieved as "1st March 1900"
Would it be best practice to store the day month & year in separate fields ?

Getting The Age In Years
i want to get the age of a person in years with sql query in mysql. i have stored the date of birth in the database. I have tried Datediff function of mysql but it returns in Days not in Years.

I would like to use some thing like this one.

select * from tablename Where "datefunction that get me date in Years like this one Datediff(CURDATE(),date_of_birth) " between agefrom AND ageto.


Do Years Begin With 1901???
I just created a new table that stores the names of Washington State governors, with separate fields for the years they began and ended office. When I filled it from my CSV file, I discovered that all the years prior to 1901 defaulted to 0000.

Is there a way to fix this, or should I just use INTEGERS instead of YEAR?

Adding Multiple Years
I have set up tables that increase input dates by either a month, quarterly, half yearly or annual using M,Q,H or Y in the default space, and ('M','Q','H','A') in the length/values space.However, I want to be able to add 5 years to one of the fields in the table.

Grouping Weeks, Months Or Years
I have a database full of log information that has a record for every hour of every day.

So I have 24 records all with the same 'dateCreated' field and then the 'timeCreated' field changes for each hour of that day.

So grouping the query results of the database into days is very simple, just a quick 'GROUP BY dateCreated' does the trick, however i now have the requirement to group that data into weeks, months and years.

What is the best way of achieving this? is it even possible?

Returning Decades From A List Of Years
I have a column containing a year and I want to return a list of the decades in that column. For example:

Year
--------
1987
1992
1914
1922
1923
1928
1984

would return:

Year
-------
1910
1920
1980
1990

Mysql Nt Service Stopped Starting After 2 Years
i have been running mysql on windows server 2003 for the last almost 2 years (its a really early version of mysql 4 anyway) but now all of a sudden mysql service stopped starting, i can go to services, press start and then refresh and its off again! i have a feeling that someone deleted the core mysql table (mysql) as it is now totally empty.

im not too good with my sql as i generally use mssql or whatever, infact mysql never really installed properly, the only user i could ever use was root but i didnt mind this so i just left it and it was fine for 2 years but now its just stopped all of a sudden and i cant get it back on.

i have enabled the mssql php exension as a backup system but i cant transfer any databases across without enabling mysql.. but it wont turn on! i tried several exes in e:mysqlin but none got it on (well one of them made the little winmysqladmin light go on for half a second)

Converting MS Access Dates To MySQL Dates During LOAD DATA INPUT ?
My insert code is below. The MySQL server is on my local machine and is version 4.1.22. I am exporting from an access table with 6 fields to a mysql table with those 6 plus 5 more fields. The main problem I am having SO FAR, is converting dates. The data file dates are formated like:
2/2/2006 0:00:00, 12/20/2006 9:22:05

Any ideas how to format those into mysql friendly dates?

Also, how do I convert currency fields in the load data process? I know you use SET by what kind of formula?

===========================================

LOAD DATA INFILE 'C:Documents and Settingspath_to_filedata.txt'
INTO TABLE auto
(field2, field3, field4, field5, currency_field6, field7, date_field8, date_field9)
SET id = MD5(UUID())
FIELDS TERMINATED BY ','
LINES TERMINATED BY '
'

How To List All Missing Dates Between 2 Dates
I have a database which stored financial data daily exclude weekend, however sometimes i tend to forget to upload data into the database. How do i write a sql query that would detect the missing dates between from last updated date until the current date.

Stroring Dates Perior To 1 AD, BC Dates
I need to store some dates that can be BC, However I received a problem indicating Incorrect Datetime.

I have read the documentation, and it says that Date&DateTime types can store from 1000-9999 AD, and Timestamp stores less year ranges. What other options do I have to store dates before 1000 AD !

List All Dates Between 2 Diff Dates
I have a database which stored financial data daily exclude weekend, however sometimes i tend to forget to upload data into the database. How do i write a sql query that would detect the missing dates between from last updated date until the current date.

Dates, Dates, Dates - Syntax Help Please!
OK, I have a MySQL table which contains, among others, a field called date which stores dates in the format YYYY-MM-DD HH:MM:SS.

What I'd like to do is select a list of all the months present (without repetition), preferably in the format YYYY-mm

Models Where The Years Overlap (was "Query Help Needed")
I'm trying to formulate a query for the following example:

Table: model_by_year
model start_year end_year
model_1 2001 2004
model_1 2003 2004
model_2 2000 2005
model_2 1998 1999
model_3 1998 2003
model_3 2002 2006

I want a query that will return all like models where the years overlap. In other words, I'd want to return model_1 and model_3, but not model_2.

Naming Years As "seasons"
In the football records database many of you have been so kind to push me along on, I have a dropdown menu that pulls each year into the list.

The problem now is adapting it for sports that play one season in two calendar years (like this year is the 2006-2007 basketball season). Is there a simple way to do this? The easiest I've come up with so far is making another table of "seasons" and use a "season_id" in the 'games' table. I've tried looking into "fiscal year" solutions, since that also spans two calendar years, but the naming conventions are different (i.e., "Fiscal Year 2006")

Storing Pdb
I am in the process of creating a database that will store amongst otherthings, will need to store .pdb files and .vrml files. I am a bit confused as to go about it, as these files have to made accessible to the user- via a perl-cgi webpage. You get the idea- you search for something and you click on "get pdb file", and the user gets it. My question is this: Can i store files just in there .pdb form, or can a field only store the text that is in the pdb file. Is there a way to just put the file onto the web browser or will it have to be printed out via the cgi script onto the web browser line by line?

Storing 30.00
to store this in mysql, is this proper:

Code:

product_price float(4,2) unsigned NULL

Storing Images In The DB
I have a database that is a catalog of movies, books, etc and I would like to have a page that actually shows an image of the item along with the title, that's not the problem, the problem is I do not know how to go about storing images in the database and assigning them to catalog entries.

Storing User CSS
I'm working on a social networking site with a friend and am curious about something: how much bandwidth do mysql queries typically consume? I'd like to make the CSS of user profiles open for editting, but that would mean a lot of css settings would have to be stored and constantly queried. Does this take up a lot of bandwidth and are there any ways to open up the CSS without consuming too much?

Storing Keywords
I did a search on storing keywords and found a post where someone suggested storing keywords in a 1-to-many table scenario. I'm not sure I follow. Here's what i'm thinking of doing. I'll be storing a Word document that would be tied to various keywords. I want to be able to search by keywords and get back a query of various documents that match up to the keywords.
I figured i'd make a page to list the document and then input keywords and store them in the database for later searching.
What would be the best way to store these keywords for each document?
hope that wasn't to confusing. Thanks for the help.

Storing Numbers
How do I store a number in this format... 2.00


Storing Arrays
What is the best datatype/method of storing an array of data retrieved from PHP. And/or do I need to convert the array to a string before inserting?

Storing Time
I need to store time in several tables and im trying to find out the best way to do it. I need to store the time in this format HH:MM (or HH:MM:SS). Im thinking of using the TIME field in MySQL 4.1.

I need to show the time with AM/PM, so i guess i should store it in a 24hr format and use DATE_FORMAT to show it with AM/PM...right?

And i will need to show them chronologically...how would i do that?

Storing Day Of Week
I need to store the day of the week an item will occur on every week. I will then be able to sort by that column by the day. I was thinking about storing it in a datetime field while putting all items in the same week but changing the date so that it coincides with the proper day of the week. I'm not sure how to do this in either the mysql query or in php.

Storing And Using Images
I am planning an extension to my website that will be based on a template.
For the sake of argument let's suppose that the page caters for 5,000 clubs. While the general layout and options can all be based on the template, I want to put each clubs logo on their own page. I realise that there are two methods, either store images in a database or in a file and call them from a link in a database. Assuming I am uploading all the images, which would be the simplest solution. I use dreamweaver 8, mysql and php.
I can see that if they were in a database, putting them onto the page would be easy but uploading them would be difficult.
If I used a file based system, uploading would be easy but I don't know how to get them onto the page.

Storing Checkbox Value
How do I store the result of a checkbox (T/F) in the database? What type is best? I've tried enum & tinyint, but the error was 'Column count doesn't match value count at row 1'.

Storing Keywords
What is the best way to store keywords in a database table.
I have a document, and want to be able to first, register various keywords associated with the document, and then have a page where the user can type in keywords to do a search for matching documents.  Then they would eventually select one document to view based on the keyword search.

So....back to storing the keywords. Do I store them all in one field, comma seperated, or is there a better method?

Storing An Array
Any tips on the best way to store an array in my database. If it helps to know, its a ruby array/hash

Storing Data
Unfortunately when I was installing FreeBSD, its handbook told me that
/var should be around 256 MB or so.

Now, since /var is near to the edge of the hdd, it is fast and now I
can't store my 2 GB+ mysql data on /var.

I'm storing the mysql data on /usr partition which is 60 GB big.

Are there any performance implications on my approach ?

Storing A Time (not Hr:min:sec)
I am trying to store a time in the form of min:sec.100th sec . This is the output from a piece of software that time various races. The only way I can get the MySQL db to keep all the data is to insert it as a text field. Putting it in as anything else will truncate to fit the data type. I.E. int become 1 from 1:03.45.

I can store it as text, however times that don't fill into the minute, (meaning less than a minute) don't sort properly. Well, they do, but not how I want them. MySQL parses 59.45 as being higher than 1:03.23, which it should, but that doesn't work for me. If I add a 0: in front of the 59.45 (0:59.45) it will work correctly, but that isn't the form the times will be given to me.

Short of modifying all the times that are less than a minute to reflect the 0:, or changing all the times over a minute to their equivalent in seconds and then working in INT's, is there any easy way to get around this?

Storing Data From Xml
I am getting xml file as input. Now I have to parse the xml and store the value in table.Can anyone give the code for this.

Storing Avg Value Of 3 Columns In 4th
I want to create a table which stores the average value of 3 columns and store that value in the 4th column.

create table Score(num1 int unsigned,num2 int unsigned,num3 int unsigned, avgnum ((num1+num2+num3)/3) int unsigned);.

Storing In Varchar
When I generate a varchar with a in it, it comes out as a funny symbol and eats a character on the right side of it.
I want to store a filepath in the db. As follows:
Input: 'c: estDataReservation.doc'

Storing UTF-8: Does BLOB
I'm trying to store UTF-8 texts into a mySQL database. These
texts contains Spanish special characters.

If I set field as VARCHAR and browse stored data, I get 'año'
instead of 'año'.

But if I set field as BLOB, and I perform
SELECT * FROM my_table WHERE my_field LIKE '%año%'
it does not work.

And
SELECT * FROM my_table WHERE my_field LIKE '%año%'
does work.

I would like to be able to work with right words... is it
possible?

Storing BLOB
Im using MySQL 4.1. How do you store an image (BLOB) into the database (without the aid of other programming softwares)?

Storing Text
what the best way (date type) is to store lots of plain text in a MySQL db.
I'm trying to store the bodies of certain html pages in it.
asmuch as a 1000 lines of code.

Storing Records
I would like to select some records from a database and write the outcome to a file. I don't know how to go about doing this. If it's possible, I would like to arrange the records in a specific way. The idea is to have a cron script do this for me once I learn how to do it manually.

Data Storing
As far as I understand numbers are in MySQL database kept as binary.
I was wondering how is data in column of type "CHAR" or "TEXT"
kept in database:
for example if I eneter "Today is Thursday and I do not go to work." in column "CHAR"
Is every letter translated into binary ?

Storing The Value 'N/A' As FLOAT
I am planning on storing a CSV file in a mySQL db. So far so good.
the thing is: I have few numeric columns with floating values (value example 52.45 or 13.25).
The problem is: these numeric columns also contain 'N/A' values when data is, well... not available.How should I store this data? I made a small test that resulted in a '0' when I tried to insert a string into a FLOAT field. Makes sense...How would your people deal with that issue?If I store the numerical data as VARCHAR - can I run mathematical calculations with it?

Storing Password
I created a form where user enters his/her username and password. I need to know how can i make mysql to store and view password field in an encrypted format not display it as regular text.

Storing Images In DB
I have read some opinions stating that it is better to store images on the file system rather than the DB. And only note the image name in the DB/table for a reference. I was wondering of some experienced members could tell me if that is a better way of doing things or storing them in the DB is just fine?
Note: This is not for an enterprise level website. It is for a very small one.

Storing Images
I want to store images in mysql database, wht should be the best choice. Issue is database size will grow on daily basis.
wht should be the best choice of storage engine

- InnoDB
- myISAM

Storing Time
I need to store times in my database. The times will be in the format of 10:15.03 minutes:seconds.milliseconds
Which data type should I select for the field in the table?
I will want to be able to sort them into order ie quickest first and also calculate the differences between each time.

Storing "
if I can do row lookups in constant time if I know what row I'm looking for, i.e. I know the row key(id). I know I can use an index to speed up queries but for what I understand it still does a b-tree search when using an index. Basically, I would like to store a "pointer" to the row and use it later to get the row without any searching overhead, is that possible and how?

Storing SHA($pass)
I'm using SHA($pass) to store passwords in mysql. My question is what should the pass colum be, is the SHA always a certain length etc. What is the column type with the least memory usage/problems etc

Storing Unlimited Variables
I want to be able to store unlimited values for each field in my database. For an example if i was storing what colour a car is available in could be one colour or an unlimited optional number of colours for each car.

I dont want to create fields for say 10 colours as i dont want to limit it.

What is the best way to do this?

The only way i can think of doing this is for example having one field called carColours set as a varchar and storing colours all in one field like blue,black,red and then splitting the field when i extract the data.

Not sure about speed issues etc?


Copyright © 2005-08 www.BigResource.com, All rights reserved