473,394 Members | 2,063 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,394 software developers and data experts.

date/time

hi all!

i need to combine 2 fields into one.
one field is a Date field and the other is a Time field.
so i need to have these combined into a Date/Time field so that i can
do some hours calculations in a query.can i do this with code in my
input form ???

thanks
brino

Oct 5 '06 #1
3 1212

brino wrote:
hi all!

i need to combine 2 fields into one.
one field is a Date field and the other is a Time field.
so i need to have these combined into a Date/Time field so that i can
do some hours calculations in a query.can i do this with code in my
input form ???

thanks
brino
you should be able to add the two together. The integer part is the
date, and the fractional part is the time. You could create an unbound
control on your form and set its controlsource to [ctlDate] + [ctlTime]

Oct 5 '06 #2
brino wrote:
hi all!

i need to combine 2 fields into one.
one field is a Date field and the other is a Time field.
so i need to have these combined into a Date/Time field so that i can
do some hours calculations in a query.can i do this with code in my
input form ???

thanks
brino
Greetings brino,

Here's one way to do it:

MyTable
theDate Date/Time m/d/yyyy
theTime Date/Time hh:nn:ss
theDate theTime
10/1/2006 15:15:00
10/2/2006 15:20:01

SELECT DateAdd("s", DateDiff("s", CDate("00:00:00"), theTime), theDate)
AS FullDate FROM MyTable;

FullDate
10/1/2006 3:15:00 PM
10/2/2006 3:20:01 PM

In code:

dtFullDate = DateAdd("s", DateDiff("s", CDate("00:00:00"), dtTime),
dtDate)

James A. Fortune
CD********@FortuneJames.com

Mr. Bojangles on online karaoke (not me):
http://www.ksolo.com/actions/showSon...2425&uid=15273

Oct 6 '06 #3

CD********@FortuneJames.com wrote:
i need to combine 2 fields into one.
one field is a Date field and the other is a Time field.

SELECT DateAdd("s", DateDiff("s", CDate("00:00:00"), theTime), theDate)
AS FullDate FROM MyTable;
I think this should work OK; maybe handle existing null values? Of
course, this should be a one-off scrubbing exercise before fixing the
design flaw e.g.

ALTER TABLE MyTable ADD
COLUMN effective_date DATETIME DEFAULT NOW() NOT NULL
;
UPDATE MyTable
SET effective_date = IIF(ISDATE(theTime), DATEADD('s', DATEDIFF('s',
CDATE('00:00:00'), CDATE(theTime)), theDate), theDate)
;
ALTER TABLE MyTable DROP
COLUMN theDate
;
ALTER TABLE MyTable DROP
COLUMN theTime
;

Jamie.

--

Oct 6 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
15
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract...
13
by: maflatoun | last post by:
Hi, I have the following function to convert UTC time to Local time. It works perfect for GMT- (Minus) time zones however it provides incorrect results for GMT+(Plus) time zones? // Format to...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
6
by: Luvin lunch | last post by:
Hi, I'm new to access and am very wary of dates as I have limited experience in their manipulation and I know if they're not done properly things can turn ugly quickly. I would like to use a...
3
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
3
by: colleen1980 | last post by:
Hi: Data in my table is in that format. How to i separate date with time. 11/9/2006 10:10:46 AM Thank You.
6
by: Geoff Cox | last post by:
Hello, at the moment I can add the combined date and time into MySQL using php $dt1 = date("Y-m-d H:i:s"); is it possible to add the date and time separately? I thought it might be
0
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any...
4
by: ahmurad | last post by:
Dear Brothers, I am struggling the following four Date-Time type values which were inputted into MYSQL database in different tables. As MYSQL Default Time Format: YYYY-MM-DD HH:MM:SS, So I used...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
marktang
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.