I am trying to convert datetime to varchar.
>From my memory (I am not 100% sure), datetime data is like "Nov 15,
2005" and
varchar data is like "2005-11-15."
Any feedback or help would be appreciated.
Thanks.(justin_doh@.yahoo.com) writes:
> I am trying to convert datetime to varchar.
>
> 2005" and
> varchar data is like "2005-11-15."
>
Datetime is stored in a binary format in SQL Server.
You can use the convert() function to convert datetime to a string.
There are a number of format codes to choose from. Look up the topic
CAST and CONVERT in Books Online.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx
Showing posts with label nov. Show all posts
Showing posts with label nov. Show all posts
Tuesday, February 14, 2012
Sunday, February 12, 2012
convert datetime to UTC seconds
Hi guys,
Do you know how to convert a datetime to UTC seconds:
eg: nov 17, 2005 21:00:00
UTC in seconds: 1132261200
thank a lot
Message posted via webservertalk.com
http://www.webservertalk.com/Uwe/Forum...amming/200511/1http://www.aspfaq.com/2451
"fasttrack via webservertalk.com" <u15121@.uwe> wrote in message
news:5783c74d47a66@.uwe...
> Hi guys,
> Do you know how to convert a datetime to UTC seconds:
> eg: nov 17, 2005 21:00:00
> UTC in seconds: 1132261200
> thank a lot
> --
> Message posted via webservertalk.com
> http://www.webservertalk.com/Uwe/Forum...amming/200511/1|||current: select datediff(second, '19700101', GetUTCDate())
given a local date:
-- use dateadd(hour, datediff(hour, GetDate(), GetUTCDate())
-- to get the current hour difference between UTC and local date
declare @.GetDateVal datetime
select @.GetDateVal = '20051117 15:00:00'
select @.GetDateVal, datediff(second, '19700101', dateadd(hour,
datediff(hour, GetDate(), GetUTCDate()), @.GetDateVal ) )
fasttrack via webservertalk.com wrote:
> Hi guys,
> Do you know how to convert a datetime to UTC seconds:
> eg: nov 17, 2005 21:00:00
> UTC in seconds: 1132261200
> thank a lot
>
Do you know how to convert a datetime to UTC seconds:
eg: nov 17, 2005 21:00:00
UTC in seconds: 1132261200
thank a lot
Message posted via webservertalk.com
http://www.webservertalk.com/Uwe/Forum...amming/200511/1http://www.aspfaq.com/2451
"fasttrack via webservertalk.com" <u15121@.uwe> wrote in message
news:5783c74d47a66@.uwe...
> Hi guys,
> Do you know how to convert a datetime to UTC seconds:
> eg: nov 17, 2005 21:00:00
> UTC in seconds: 1132261200
> thank a lot
> --
> Message posted via webservertalk.com
> http://www.webservertalk.com/Uwe/Forum...amming/200511/1|||current: select datediff(second, '19700101', GetUTCDate())
given a local date:
-- use dateadd(hour, datediff(hour, GetDate(), GetUTCDate())
-- to get the current hour difference between UTC and local date
declare @.GetDateVal datetime
select @.GetDateVal = '20051117 15:00:00'
select @.GetDateVal, datediff(second, '19700101', dateadd(hour,
datediff(hour, GetDate(), GetUTCDate()), @.GetDateVal ) )
fasttrack via webservertalk.com wrote:
> Hi guys,
> Do you know how to convert a datetime to UTC seconds:
> eg: nov 17, 2005 21:00:00
> UTC in seconds: 1132261200
> thank a lot
>
Subscribe to:
Posts (Atom)