I am usig Calender extender control to select date.it works fine but the issue is while storing in SQL table the date is stored with Defaulttime like below:
"10/7/2008 12:00:00 AM".My Requirement is like if a customer calling yesterday 10.30AM .Today I am entering the Customer calldetails date " 20-10-08 " with time 10:30AM it has to be stored like 20-10-08 :10.30AM.I want to know the
following details
1)Is there any control to select Date and Time simultaneously.
2)How to Enter the Date and Time in Storedprocedure.(Here the Time meant not default time but user defined time like 10:30AM.plz kindly let me know its very urgent.
You've to format the value returned by sql server on the front end, alternatively you could set the datatype of that column to varchar, however, it is not at all the preferred way of doing away with this problem but may fastly come to your rescue [:$]
This way works, but there may be more efficient ways to handle it depending on when/where you are handling the values. This assumes you have the saved date as a datetime SQL type and the time portion is sent in to a stored procedure as a varchar.
declare
@date datetime
declare @time varchar(25)
-- use AM/PM
-- set @time = ' 02:45:00 PM'
-- use 24 hour clock
set @time =
' 14:45:00'
set
@date =
cast(getdate()
as datetime)
-- concatenate the date and time values by converting the date to a varchar
-- then adding the time portion, then casting the new string to a single datetime value
-- using convert code 101 ensures any existing time portion from the saved date will not
-- be included
set @date =
cast(convert(varchar, @date,
101) + @time
as datetime)
suresh_dotne...
Member
8 Points
188 Posts
How to select Date and Time simultaneously
Oct 21, 2008 01:41 PM|LINK
Hi:
I am usig Calender extender control to select date.it works fine but the issue is while storing in SQL table the date is stored with Defaulttime like below:
"10/7/2008 12:00:00 AM".My Requirement is like if a customer calling yesterday 10.30AM .Today I am entering the Customer calldetails date " 20-10-08 " with time 10:30AM it has to be stored like 20-10-08 :10.30AM.I want to know the following details
1)Is there any control to select Date and Time simultaneously.
2)How to Enter the Date and Time in Storedprocedure.(Here the Time meant not default time but user defined time like 10:30AM.plz kindly let me know its very urgent.
Thanks
ASP.NET 2.0 - Ajax
shashankgwl
All-Star
18926 Points
3662 Posts
Re: How to select Date and Time simultaneously
Oct 21, 2008 03:29 PM|LINK
You've to format the value returned by sql server on the front end, alternatively you could set the datatype of that column to varchar, however, it is not at all the preferred way of doing away with this problem but may fastly come to your rescue [:$]
All is well if it runs well.
blog
lmcculloch
Member
110 Points
27 Posts
Re: How to select Date and Time simultaneously
Oct 21, 2008 03:58 PM|LINK
This way works, but there may be more efficient ways to handle it depending on when/where you are handling the values. This assumes you have the saved date as a datetime SQL type and the time portion is sent in to a stored procedure as a varchar.
declare
@date datetimedeclare @time varchar(25)
-- use AM/PM
-- set @time = ' 02:45:00 PM'
-- use 24 hour clock
set @time = ' 14:45:00'set
@date = cast(getdate() as datetime)-- concatenate the date and time values by converting the date to a varchar
set @date = cast(convert(varchar, @date, 101) + @time as datetime)-- then adding the time portion, then casting the new string to a single datetime value
-- using convert code 101 ensures any existing time portion from the saved date will not
-- be included
select
@Date, @time