473,847 Members | 1,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2674
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**********@g mail.com> wrote in message
news:11******** *************@c 13g2000cwb.goog legroups.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_Valu eChanged(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles pickerDate.Valu eChanged
pickerTime.Valu e =
pickerDate.Valu e.Date.Add(pick erTime.Value.Ti meOfDay)
End Sub

Private Sub pickerTime_Valu eChanged(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles pickerTime.Valu eChanged
Me.labelDateTim e.Text = pickerTime.Valu e.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******** ******@TK2MSFTN GP10.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******** ********@TK2MSF TNGP10.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**********@g mail.com> wrote in message
news:11******** *************@c 13g2000cwb.goog legroups.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
5232
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 appreciated. TIA
15
18899
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 the value in timeonly format by using this command Format(now,"HH:mm:ss") But when I insert it into the Sql Server database, it embadded date value with it. the output looks like that "01/01/1900 08:59:00" in that case time is
13
16184
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 local time from UTC function formatToLocalTimeDate(inDate) { var today = new Date(); var inDateMod = new Date(inDate);
12
29490
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 follows: function doDateCheckNow(source, args) { var oDate = document.getElementById(source.controltovalidate); // dd/mm/yyyy
6
12567
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 calendar control to allow my users to enter a date but I need them to enter a time as well. It doesn't look like the calendar control will allow times to be entered so I was thinking of having two text boxes. One text box would contain the date...
3
3322
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 the field should only be showing one or the other (date or time). Even on the back end of the database where the column properties are, I have chosen the smallest date/time formats. When the aspx page runs, it shows the date and time (ie:in a...
3
12967
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
3943
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
16517
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 formatting considerations at all. They are simple, easy, and brief and you should use them any time you need to incorporate any date literals or date math in your T-SQL code. create function DateOnly(@DateTime DateTime) -- Returns @DateTime...
4
32963
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 the MYSQL Tables DateTime Type as Text. Time-formet 1. 04:02:27 16/01/2009 Time-formet 2. 16/01/2009 13:53:19 Time-formet 3. 00901E+13 Time-formet 4. Wed Jan 14 00:09:09 BDT 2009
0
9892
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10995
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10654
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10718
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7888
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7061
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4130
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3168
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.