473,598 Members | 3,409 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 2661
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
5207
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
18877
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
16144
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
29442
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
12536
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
3284
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
12908
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
3932
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
16485
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
32947
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
7991
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
7902
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8395
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...
1
5850
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
5438
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();...
0
3898
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2412
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
1
1504
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1250
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.