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

Date and Time

Hi Guys

I have two DateTime pickers one shows the Date and the other the time, this
is a requirement of the solution. The problem I have is that when the time
is saved to the sql database into a datetime field it uses the default date
which is a problem when I try to sort, what I wanted to know is there a way
for me to set the date in the time picker to the date in the date picker?

Any help greatly appreciated.

Thanks
Mike

Nov 21 '05 #1
4 2644
I am going to assume that you HAVE to store the time into a datetime
field within SQL.

Before you save the values you can store the datetime value by taking
the date value of the date picker and putting the time value behind it.
Then you can through the time value into your db with the correct date
in front of it. This seems a tad askew though

hth

Nov 21 '05 #2
OK, if you can think of a better way the onyl requirement is that the date
is in one picker and the time is in another, please let me know I would be
more than interested, I am taking over someone elses project so I am just
trying to fix the problems so a different way would suit me fine.

Mike.

"Not Aaron" <aa**********@gmail.com> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.com...
I am going to assume that you HAVE to store the time into a datetime
field within SQL.

Before you save the values you can store the datetime value by taking
the date value of the date picker and putting the time value behind it.
Then you can through the time value into your db with the correct date
in front of it. This seems a tad askew though

hth


Nov 21 '05 #3
MIchael,
You should be able to set the Value of your Time picker to the Date of the
Date picker & the Time of the Time picker, when the Date picker's value
changes.

Something like:

Private Sub pickerDate_ValueChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles pickerDate.ValueChanged
pickerTime.Value =
pickerDate.Value.Date.Add(pickerTime.Value.TimeOfD ay)
End Sub

Private Sub pickerTime_ValueChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles pickerTime.ValueChanged
Me.labelDateTime.Text = pickerTime.Value.ToString()
End Sub

Where pickerDate is a DateTimePicker for the Date value & pickerTime is a
DateTimePicker for the Time value.

I would consider encapsulating both controls into a new User Control to
allow easier reuse & better encapsulation...

Hope this helps
Jay

"Michael Turner" <fi*****@m-turner.co.uk> wrote in message
news:ut**************@TK2MSFTNGP10.phx.gbl...
Hi Guys

I have two DateTime pickers one shows the Date and the other the time,
this is a requirement of the solution. The problem I have is that when the
time is saved to the sql database into a datetime field it uses the
default date which is a problem when I try to sort, what I wanted to know
is there a way for me to set the date in the time picker to the date in
the date picker?

Any help greatly appreciated.

Thanks
Mike

Nov 21 '05 #4
Michael,
Do you have a single datetime field on the database or 2 datetime fields?

I would expect a single datetime field.

Using the code I posted earlier you can use 2 DateTimePickers, but store
both values in a single database field.

Hope this helps
Jay
"Michael Turner" <fi*****@m-turner.co.uk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
OK, if you can think of a better way the onyl requirement is that the date
is in one picker and the time is in another, please let me know I would be
more than interested, I am taking over someone elses project so I am just
trying to fix the problems so a different way would suit me fine.

Mike.

"Not Aaron" <aa**********@gmail.com> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.com...
I am going to assume that you HAVE to store the time into a datetime
field within SQL.

Before you save the values you can store the datetime value by taking
the date value of the date picker and putting the time value behind it.
Then you can through the time value into your db with the correct date
in front of it. This seems a tad askew though

hth


Nov 21 '05 #5

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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
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,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.