Re: Number to Date.
From: Vishal Parkar (REMOVE_THIS_vgparkar_at_yahoo.co.in)
Date: 04/05/04
- Next message: Dylan: "Re: Number to Date."
- Previous message: Dylan: "Number to Date."
- In reply to: Dylan: "Number to Date."
- Next in thread: Dylan: "Re: Number to Date."
- Reply: Dylan: "Re: Number to Date."
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 5 Apr 2004 23:53:41 +0530
hi Dylan,
create table date_log (dt int)
insert into date_log values(20040405)
--you write a query to make conversion to datetime as follows.
select convert(datetime, cast(dt as char(8))) 'dt' from date_log
Make use of datetime datatype instead to avoid datetime value overflow errors and to insert
valid values of date datatype range. This is because datetime store dates in the range from
January 1, 1753 through December 31, 9999. However if you make use of INT datatype to store
datetime value,it can accept value of Dec 31, 1752 (which will be converted to integer as
17521231) though this valid integer its not a valid datetime value.
Ex:
insert into date_log values(17521231)
--Integer value can be inserted into above
select convert(datetime, cast(dt as char(8))) 'dt' from date_log
--in above query which tries to convert integer 17521231 to datetime, you will get an error as
The conversion of a char data type to a datetime data type resulted in an out-of-range
datetime value.
-- Vishal Parkar vgparkar@yahoo.co.in
- Next message: Dylan: "Re: Number to Date."
- Previous message: Dylan: "Number to Date."
- In reply to: Dylan: "Number to Date."
- Next in thread: Dylan: "Re: Number to Date."
- Reply: Dylan: "Re: Number to Date."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
- Query Data using Date
... Install SQL Server 2000 Developer Edition. ... I want to query a table
which contains a column of data type datetime using ... (microsoft.public.sqlserver.programming) - Re: Date Conversion
... The problem that I am having is the format of the date because if I actually ...
> Infact you dont require a conversion in that place, ... > datetime datype.
... >> The conversion of a char data type to a datetime data type resulted in ...
(microsoft.public.sqlserver.server) - Re: SQL bug, ISNULL function with smalldatetime
... didn't even think about the rounding and re-implicit conversion to ... >>For
@dateParam, ... >>DECLARE @dateParam datetime ... > smalldatetime,
rounded to the nearest full minute: 2005-02-10T00:54. ... (microsoft.public.sqlserver.programming) - Re: Time Conversion
... You could do the conversion manually. ... TimeSpan span = TimeSpan.FromSeconds;
... DateTime dateTime = base + span; ... which is Time in seconds since UTC
1/1/70 in theory. ... (microsoft.public.dotnet.languages.csharp) - Re: Formatting DateTime with an offset
... DateTime a is sealed value type so you can not extend it. ... would like my
users to be able to specify their prefered TimeZone. ... I have written the code to do
the timezone conversion. ... rather have DateTime.ToString go through some kind of formatting
that ... (microsoft.public.dotnet.framework.aspnet)