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


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





DateTime Without Time


I have a difficult case and need your advice:

For managing events in my online application I need to be able to input the start and end.

They can be inserted either as a date only or as a date and time both.

And I save this data into the DATETIME format. The problem is, if only a date is inserted, MYSQL will put the missing time information automatically as '00:00:00' but I don't want this.

Because it will display the time as '00:00:00' which is wrong. Is there no way to save into DATETIME format without the time?




View Complete Forum Thread with Replies

Related Forum Messages:
Comparing Datetime And Time
I need to compare two values : the first one is in DATETIME format and the second one in TIME format. If I compare the two values with an usual operator, will MySQL extract the "time" part of the DATETIME and compare it to the TIME value?

If not, what function can I use to extract the "time" value? I have noticed the existence of TIME(expr) function, that extracts the TIME value from 'expr'... but it works only if 'expr' is a string, not a DATETIME.

View Replies !
Elapsed Time Between 2 DateTime Values
MySQL Version 4.0.20 on a Linux server.

How does one get the elapsed time between (2) DateTime values?
I need the answer to the nearest minute.

Is upgrading to Ver 5 with its more robust date/time functions the only
solution?

You can directly subtract 2 DateTime values and a long integer results.
What is that number?

View Replies !
Datetime Field Updateing Time Only
How would I update the time only on a datetime field? The filed is: "2008-09-14 12:06:00" and I want to change it to "2008-09-14 12:16:00".

If I use

 update field_name set field_name = TIMEDIFF('2008-09-14 12:06:00', '2008-09-14 12:16:00'); 

View Replies !
Update Time Ony In Datetime Field
How do I update the time portion in a datetime type field? There are several rows containing various times and I want to make them all the same: 11:30:00.


I have tried doing the following w/o success:
update field set field = "date(field) 02:02:00"

View Replies !
Update Just Time In Datetime Column
I have a datetime column called foo, it currently has dates in it with all times set to "00:00:00".

I would like sql to update all the rows and set the time to "15:15:00" but leave the dates as they are today.

View Replies !
Datetime :: 12 And 24 Hours Time Format
I am using webservice to download data from mySQL to SQL Server.

I noticed in sql server datetime format makes the hour 12 to 00. for example

2008-06-12 00:40:47.000

This is really 2008-06-12 12:40:47.000

My question is how does mySQL treats 24 hours format. with 12 or 0 for the hour "12".

View Replies !
Function To Convert From DateTime To Relative Time
I have a DATETIME column and I looking to write a function which does the following:

Takes in the DATETIME and compares it against the current time, and returns a string in any of the forms below, depending on the value of the DATETIME:

'You updated your settings 4 seconds ago.'
'You updated your settings 2 minutes ago.'
'You updated your settings 6 hours ago.'
'You updated your settings 12 days ago.'

But its smart and automatically scales from seconds, to minutes, to hours, to days, rounding either up or down.

View Replies !
Convert Time Format DATETIME To MFC/MS Visual C++ 6.0
How to convert format DATETIME to MFC/MS Visual C++ 6.0.
I get get datetime from mysql database using mysql++ api.
I wanna put this datetime into Edit Box in MS Visual C++.

View Replies !
Current Date & Time For Datetime Variable?
I have created a table with a variable of the type "datetime". Any one knows how to update this variable with the current date and time? The function Curdate() only updates the date, not the time.

View Replies !
Combining Date And Time Fields Into A Datetime Field
I have a table with separate Date and Time fields.

Is there a way to either:

1. Convert the date and time fields into a combined datetime field?

or

2. Create a datetime value in the select statement so I can select all records before a given date and time?

View Replies !
Creating Datetime Data Object From Date And Time Objects
I have date and time objects that correspond to eachother. I want to add a certain amount of minutes and hours to them and get the resulting date and time.

I was planning on creating a datetime datatype from the two and then using the date_add() function and then convert back; however, I do not know how to create a datetime object from two seperate date and time types and then back to seperate types, or whether it is even possible.

View Replies !
Generating DAILY Min&Max Over A Period Of Time, Based On A "DateTime" Field
how to print the minimum and maximum of a specific field, between two datetimes (both having the time 02:00:00) - so I did this:

WHERE ((tblvalues.dtLPDateTime)>="2006-01-01 02:00:00" And (tblvalues.dtLPDateTime)<"2006-01-03 02:00:00"))

Now I want to print those min and max values but for each day in this cycle, i mean, for this example, there would be two records like:
Day Min Max
2006-01-01 02:00:00 -> 2006-01-02 02:00:00 | 40 | 59
2006-01-02 02:00:00 -> 2006-01-03 02:00:00 | 49 | 68
where at this point i`m getting min=40 and max=68

View Replies !
Compare Datetime Field With Todays Datetime
How do I compare a datetime field in the database with todays datetime...

Is it:

if rs("fieldname")<>getdate() then
....
else
(gotto set a cookie here)
end if

Somebody suggested I use cdate...what is tht for..is it to make sure they are both in the same format or something.. if so how do I use it?

View Replies !
PHP/MySQL Sorting By Date & Time (using Non Military Time)
This is probably a simple issue but I have searched online and can't find an answer.

I am using PHP/MySQL and I guess the most intuitive would be to have three select boxes containing HOUR / MINUTE / AM,PM option. Then store the time into mysql using there functions so I can output the data sorting them all by date and time. All the examples I have seen are for military time only but I'm sure there has got to be a simple mysql function or php function that converts non military to military and a formatting function to display with the AM / PM. But I have not found it.


View Replies !
Compare Time Posted With Current Time Not Working
May I know how to get records with interval of 1 hour in database where the posting time is in this format '2008-05-15 00:10:40'

I tried with this :

$query="SELECT date,name FROM message WHERE (timediff(date,NOW())<=CRUDATE() CURTIME())";

But is not working. May I know what is the correct way of doing it?

View Replies !
Different Timestamps For Time Of Creation And Time Of Update
What is the syntax to be used in MySQL when you want one timestamp to be set when the record is created, and the other only when it is updated?

I tried something like that but got a syntax error.

View Replies !
Minutes + TIME = TIME Function
I need some way to convert minutes (e.g. 80 mins) to SQL TIME (e.g. 01:20:00) in order to add it to another TIME var.

Is there any way to do this? I really dont want to convert my whole db. Basically, I want to do: e.g. 80 + 10:00:00 = 11:20:00.

View Replies !
How To Retrieve Mean Time Between Time Stamps
I have a table that stores failure information of external application. The time stamp of every failure event is stored. Now I'd like to make some system performance & reliability statistics calculations based on time stamps in certain recordset; mean time between failure MTBF, down time DT, etc.

Example:

2007-09-27 12:23:52
2007-09-27 08:50:23
2007-09-26 23:31:34
2007-09-26 21:45:33

Here the times between are (hours:mins): 3:33, 9:18, 1:46 and MTBF=4:52

Any effective possibility to make this example within a single query - or a procedure is needed?

View Replies !
Time Format Military Time
I know the time format it HH:MM:SS in mysql but can I input military time?
reason I can is that I want to later extract that information for calculations and military time is easier to work with.

View Replies !
Date-time Overlaps Another Time
had a time question in mysql...
i have a start and end time for a meeting table and i am comparing whether a new meeting conflicts with another meeting in same room on the same date.
i was wondering if i could check whether the 'date-time duration' in anyway overlaps another meetings date-time duration. visualized below...
............|____compareToThisMeeting__|
.....|_________meetingNewOverlaps__________|
i was doing something dumb before i realized i needed soemthing more complex (checking whether the start time of new meeting was 'BETWEEN' the start and end times of a meeting and whether the end time time is as well but i forgot the duration/middle value hehe).
(using asp)
and just returning booleans with a mySQL SELECT statement is what i am looking for like...
//within a loop in asp for meetings on same date/room
"SELECT '"+ year+"-"+month +"-"+day +" " + startHourString +":" + startMinuteString +":00''"+ " BETWEEN '"+ thisMeetingStart +"' AND '"+ thisMeetingEnd +"'"; (this doesnt cover the 'middle' overlap areas though)

View Replies !
Time And The Change Of Time For The Summer
I have a xampp server with mysql and php. A few days ago the time changed to the "summer time", one hour plus but the curtime() of mysql did not change.

Is there a way to change also this curtime() automatically?

View Replies !
Add Time :: 2 Hours To Given Time
how I can add a time of 2 hours to a given time (hh:mm:ss)?

View Replies !
Datetime Value
I need to return a datetime value like this: yyyy-mm-dd hh:mm:ss. The question is, performance wise, would I be better off storing the datetime value in a datetime column which takes up 8 bytes, and returns the data directly, or would I be better off storing it in an INT which takes 4 bytes, and then when selecting it do: from_unixtime(columnname)
Which would be the better choice?

View Replies !
DATETIME And UTC
I am currious does anyone know if I have a DATEIME Column if I can pass it a UTC and have it work properly. (not at a place I can test it at would love to know before I am).

So pass 1124908190.99 and have it in the DB as a DATETIME.

View Replies !
Datetime Now
in Mysql Control Center I have created a column DateTime
the default value shown is 0000-00-00 00:00:00

I have try to change it by now but it doesn't work
how can you get automaticly the current time?

View Replies !
Need Help With DateTime !
I have a table i.e. Schedule and it has a datetime column i.e. Start and it has the following records.

2007-11-21 08:55:12
2007-11-20 08:55:12
2007-11-19 08:55:12
2007-11-18 08:55:12
2007-11-17 08:55:12
2007-11-16 08:55:12

If the current date time is "2007-11-19 08:55:12" how will I come to know what is the very next date that is greater than this? and what is the very previous date that is less than this datetime? Technically speaking what statement/query may I use to get this?
In this case "2007-11-20 08:55:12" will be the very next date and "2007-11-18 08:55:12" will be the previous date.

View Replies !
DateTime
How do I insert the current date and time into a DateTime column using an SQL INSERT INTO statement.

View Replies !
Timestamps To DATETIME
I have a table that has a field that is a BIGINT and it contains unix timestamps. I want to convert them to the MySQL DATETIME format.
So I created a second field of DATETIME type and I want to run an UPDATE query that will take the value out of the first field convert in to insert into the second field.
Something like:Code:

UPDATE `table` SET `new_datatime` = UNIX_TO_DATETIME(`old_unixtimestamp`);

I don't know if a function like that (UNIX_TO_DATETIME) exists in MySQL.

View Replies !
MySQL Datetime
I'm trying to set up an RSS 2.0 feed and in order for it to be vaild I need to convert a datetime column in my database to an RFC-822 date-time (Wed, 02 Oct 2002 08:00:00 EST).

I'm using the following SQL, but am returning NULL in the date_format column from the query:

SELECT article_id AS id, article_title AS title, article_deck AS deck, DATE_FORMAT( 'article_date_added', '%a, %d %b %Y %T' ) AS date_format
FROM article
WHERE article_id =24 LIMIT 0 , 30

View Replies !
Datetime :: How To Pass Value?
How to pass datetime value to insert in mysql?

i need date like this: dd/mm/yyyy, and mysql use date like yyyy/mm/dd..

In delphi 7: This is what i´m trying to do and it´s no working.

Parameters.ParamByName('dtche').value:=strtodatetime(FormatDateTime('dd/mm/yyyy',date) + ' ' + FormatDateTime('hh:mm:ss', time));

View Replies !
Datetime Not Working
I am trying to add a date that a blog post was posted. However, the date is not changing.. it is remaining as 0000-00-00 00:00:00

This is my code:

PHP Code:

 $sql = "insert into entries (id, cat_id, dateposted, subject, body) 
values
('$_POST[id]', '$_POST[cat_id]', '$_POST[dateposted]', '$_POST[subject]', '$_POST[body]')";
mysql_query($sql); 

I have a feeling it is something to do with the
$_POST[dateposted]
as there is not actually a field in my form for dateposted

View Replies !
Splitting Up DATETIME
I have 3 drop down menus that display the day (values 1-31), month (values 1-12, and year (2005-2008). I need to be able to search the database for an event on a specific date and order them by today and on. My row is called date and its column type is datetime. Is there any way I can split up the datetime so each drop down can search a portion of the date? I'm using php if that helps any.

View Replies !
Select Datetime
i am getting started with some development for work, and i need to know how to select a time that is exactly 24 hours ago.
in the history table of my database, i have a datetime object formatted like this
2005-10-23 09:23:54
about 20 or so records going in there each day, and i need to find the value of this time yesterday. i looked at the mysql docs and reference manual, but it is a bit cryptic.

View Replies !
Index Datetime
I'm trying to retrieve results within a date range and have an index on a datetime field.
The following works correctly. Using explain i can see my index in use and only 1 record returned.Code:

SELECT * from table where date = '2006-09-01 12:30:00'

Once I change the "=" it blows up. The following query uses no index and therefore references every record before returning any results.Code:

SELECT * from table where date >= '2006-09-01 12:30:00'

Using LIKE helps, but it doesn't allow me to use an end date in the range.Code:

SELECT * from table where date like '2006-09%'

View Replies !
Selecting Datetime
I'm working with a table (that I didn't create) where the month, day, year, hour, and minute are entered into separate fields. Is there a way to select all of those from the database in datetime format? I just want one piece of data I can work with.

View Replies !
Datetime 8 Bytes
How MySQL operates sometimes makes me question it. I noticed, that the datetime in MySQL is 8 bytes. But, the date datatype is 3 bytes, the time datatype is 3 bytes, and the year datatype is 1 byte...that adds upto 7 bytes, and we get exactly that in the datetime in 8 bytes.
Why? And would this every change in future release versions?

View Replies !
Strings To Datetime
If I run the query Select '2006-12-14' + ' ' + '10:24:40'; in MS SQL Server
the result 2006-12-14 10:24:40 is returned as I expect.


If I run the same query in MySQL, 2016 is returned. Why?

What I want is to update a datetime field from two char fields containing the date and time parts in the above formats.I, therefore, run Update Tablename Set z=x+' '+y; where z is a column in datetime format and x and y are in char format and contains values like the above.Again this works perfectly in SQL Server but it fails in MySQL.Why? And what can I do about it.

View Replies !
Datetime Ranges
What is the right way to ask for records with a datetime field from the last X hours (from the last 24 hours or 72 hours for example?) in a query?

View Replies !
DATETIME -&gt; DATE
I have a table with a DATETIME column named 'date'. I find that my queries often do 'DATE(`date`)' and so I figure that it'd make more sense to have a column with the actual date in it, rather than the DATETIME. I could then make that column an index which would speed up my queries.Does that make sense?If so, how best to do this. Something like this?

ALTER TABLE rawdata ADD daydate DATE after date, ADD INDEX (daydate);
UPDATE rawdata SET daydate=DATE(date);

It seems wasteful/etc to duplicate the actual date, but I can't remove the DATETIME column since it's already used in other applications. Is there some way to have a column whose value is automatically derived from another column?

View Replies !
Datetime Vs Char(19)
I have a table that has a datetime field filled from a web server log file. It will always be the same format, ie "YYYY-MM-DD HH:MM:SS".

I want to make an index on just the "YYYY-MM-DD" part (ie char(10)), which doesn't seem to work on a datetime field, but if I convert it to a char(19), it does. What am I losing by converting my datetime field to char(19)?

View Replies !
DATETIME Fields
Why can i no longer update my datetime fields?

SELECT * FROM x200806 WHERE MONTH(stamp)<>'6'
# =755 records

UPDATE x200806 SET DAY(stamp)=1, MONTH(stamp)=6 WHERE MONTH(stamp)<>'6'
# syntax error (likewise if i say '1' instead of 1)

UPDATE x200806 SET DAY(stamp)='1', MONTH(stamp)='6' WHERE DAY(stamp)='30' AND MONTH(stamp)='5'
# syntax error

UPDATE x200806 SET DATE(stamp)=STR_TO_DATE('1/6/2008','%d/%m/%Y') WHERE DAY(stamp)='30' AND MONTH(stamp)='5'
# syntax error

UPDATE x200806 SET stamp=STR_TO_DATE('1/6/2008','%d/%m/%Y') WHERE DAY(stamp)='30' AND MONTH(stamp)='5'
# Duplicate entry '2008-06-01 00:00:00-928897152' for key 2
But i dont want the time part changed to Zero !!

I used to be able to say SET DAY(stamp)=1 but this doesnt work any more.

View Replies !
DATETIME - Set Default Value
I have a database table (MYSQL v5.0.67) in which I store several date fields. I have set these all to be not null and to have a default value of '0000-00-00 00:00:00' e.g.

`last_login` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',

However when I run my create database script (generated from a schema design in MYSQL Workbench) it complains as follows:

Error Code : 1067
Invalid default value for 'last_login'

I leave it as nullable with no default value and run the script to create the table which works fine. I can then use a tool like SQLyog to alter the table generated and set this to be not null with a default of 0000-00-00 00:00:00 and it is happy to alter the table. Obviously this is not ideal and it should work straight from the script.

View Replies !
Incorrect Datetime Value
i have 2 servers running MySQL 5.1.11
on both there is a database with a table, and there is a column called call_start, that has DATETIME datatype.

on first server i can do: SELECT * from calls where call_start like "2008-05%"
This would show me all entries from May 2008.

Its working on first server but on second i am getting:

Incorrect datetime value "2008-05%" at row 1

View Replies !
BigInt Value To Datetime
I'm looking to do two things:

I've got a table with the primary key as a recorded date "RecDate". It's formatted as BigInt(20) with a format of YYYYMMDDHHMM. The data within this table is automatically updated using a weather station updater "vwsql" I want to add a new column "RecordedDate" as a DateTime and update all previous rows to include the RecDate in Datetime format. I understand that I will need two extra digits appended (for seconds) before I can insert the value into the new DateTime column.

To achieve this would I use a union with another column containing 00 or is there an easier way?

Once I've done that, I also want to set up the above function to run automatically. Would I define a Stored Procedure and then call it from a TRIGGER AFTER UPDATE?

View Replies !
Server's Datetime
I use powerbuilder with mysql database.I want to get server's datetime.

View Replies !
Index On DateTime.
I have a datetime column in a table and I'm just curious if a normal index is suitable for these type of columns? Also, when I use the EXPLAIN command to see what key is being used, it is using Date but I have no column named Date.
My where clause is as follows:
WHERE fin._Date >= '2004-05-01 00:00:00' AND fin._Date <= ' 2004-07-07 00:00:00'

View Replies !
Format Datetime In PHP
How do i format datetime in php

<?PHP
$date="select date_format(NOW(), %W %d %M %Y %r ='$row[date]' ";
echo{$row['date']};
?>

View Replies !
Incorrect Datetime Value ...
This works on my test server, but not on my customer's server. I'm using a slightly older version of MySQL (4.0.25-nt).

I'm trying to input a datetime into the a field and get an error. The value is coming from a Date field in an MS Access 2k3 mdb. I've even tried to cDate() the value prior to putting it into the the INSERT query, same result. I've also tried using apostrophes (') instead of quots, to no resolve. The error is as follows:

Microsoft OLE DB Provider for ODBC Drivers error '80040e31'

[MySQL][ODBC 3.51 Driver][mysqld-5.0.21-community-nt]Incorrect datetime value: '2/5/2002 7:29:11 PM' for column 'ADD_DM' at row 1

The SQL Statement is as follows (shortened with elipse):

INSERT INTO tblusr VALUES ("6", ... , "1", "7/3/2005 4:19:27 PM", "7/3/2005 4:19:27 PM");

I'm working on a string converting function to resolve this for now, however this leads to some serious issues. Now() won't either ..

View Replies !
DATETIME Was How Many Minutes Ago?
I have a DATETIME stamp in a mysql database and wish to find out how many minutes ago it was... looked across mysql.com for this but no luck.

View Replies !
DATETIME DEFAULT Now().
I would like to know in what way, I can set the default value of a DATETIME field to Now() so I don't need to put the code in my scripts.

ALTER TABLE `tbltest` CHANGE `TheDate` `TheDate` DATETIME DEFAULT 'Now()'

With the ' ' it doesn't error, but it's probibly just sending the string "Now()" and I get the default date 0000-00-00.
If I take off the ' ' I get an error.

Anyone know a way I can set my default value for my DATETIME field to automatically insert the date and time with each new record?

View Replies !
Differences In Datetime
I've been reading the MySQL manual datetime function for the past 30 mins but I'm still confused.

I'm trying to select all records from a table where the postdate is later/more recent that a lastlogin time.

I tried using DATEDIFF but got a MySQL syntax error. Can someone advise me. thank you.

SELECT *
FROM table
WHERE date >''2005 -01 -25 17 :24 :47'

this query only return one row which has date = '2005-01-25 17:34:25'.

View Replies !

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