dbTalk Databases Forums  

convert string to date

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss convert string to date in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Pingx
 
Posts: n/a

Default convert string to date - 03-14-2008 , 06:26 PM






Fri Feb 29 16:46:39 America/Los_Angeles 2008

Hi, I'd like to know how I can convert the above string to a date.

Thanks in advance.

Pingx

Reply With Quote
  #2  
Old   
lonnye
 
Posts: n/a

Default RE: convert string to date - 03-16-2008 , 09:02 PM






Check out books online and look at the convert function.
It's syntax is CONVERT ( data_type [ ( length ) ] , expression [ , style ] ).
I dont have access to a sql server at this moment, but I would imagine doing
something like:
If Fri Feb 29 16:46:39 America/Los_Angeles 2008 were in a colum named
the_date...
declare @date_st varchar(30)
set @date_st = substring(5, 7, the_date) + substring(41, 4, the_date) +
substring(11,9, the_date)
convert(datetime, @date_st)
This is just off the top of my head so I apologize if anythign is wrong -
what I did was pull the Feb 29, add the 2008, then add the time part... and
convert that to datetime.
Hope this helps.
--
~lb


"Pingx" wrote:

Quote:
Fri Feb 29 16:46:39 America/Los_Angeles 2008

Hi, I'd like to know how I can convert the above string to a date.

Thanks in advance.

Pingx

Reply With Quote
  #3  
Old   
lonnye
 
Posts: n/a

Default RE: convert string to date - 03-16-2008 , 09:02 PM



Check out books online and look at the convert function.
It's syntax is CONVERT ( data_type [ ( length ) ] , expression [ , style ] ).
I dont have access to a sql server at this moment, but I would imagine doing
something like:
If Fri Feb 29 16:46:39 America/Los_Angeles 2008 were in a colum named
the_date...
declare @date_st varchar(30)
set @date_st = substring(5, 7, the_date) + substring(41, 4, the_date) +
substring(11,9, the_date)
convert(datetime, @date_st)
This is just off the top of my head so I apologize if anythign is wrong -
what I did was pull the Feb 29, add the 2008, then add the time part... and
convert that to datetime.
Hope this helps.
--
~lb


"Pingx" wrote:

Quote:
Fri Feb 29 16:46:39 America/Los_Angeles 2008

Hi, I'd like to know how I can convert the above string to a date.

Thanks in advance.

Pingx

Reply With Quote
  #4  
Old   
lonnye
 
Posts: n/a

Default RE: convert string to date - 03-16-2008 , 09:02 PM



Check out books online and look at the convert function.
It's syntax is CONVERT ( data_type [ ( length ) ] , expression [ , style ] ).
I dont have access to a sql server at this moment, but I would imagine doing
something like:
If Fri Feb 29 16:46:39 America/Los_Angeles 2008 were in a colum named
the_date...
declare @date_st varchar(30)
set @date_st = substring(5, 7, the_date) + substring(41, 4, the_date) +
substring(11,9, the_date)
convert(datetime, @date_st)
This is just off the top of my head so I apologize if anythign is wrong -
what I did was pull the Feb 29, add the 2008, then add the time part... and
convert that to datetime.
Hope this helps.
--
~lb


"Pingx" wrote:

Quote:
Fri Feb 29 16:46:39 America/Los_Angeles 2008

Hi, I'd like to know how I can convert the above string to a date.

Thanks in advance.

Pingx

Reply With Quote
  #5  
Old   
lonnye
 
Posts: n/a

Default RE: convert string to date - 03-16-2008 , 09:02 PM



Check out books online and look at the convert function.
It's syntax is CONVERT ( data_type [ ( length ) ] , expression [ , style ] ).
I dont have access to a sql server at this moment, but I would imagine doing
something like:
If Fri Feb 29 16:46:39 America/Los_Angeles 2008 were in a colum named
the_date...
declare @date_st varchar(30)
set @date_st = substring(5, 7, the_date) + substring(41, 4, the_date) +
substring(11,9, the_date)
convert(datetime, @date_st)
This is just off the top of my head so I apologize if anythign is wrong -
what I did was pull the Feb 29, add the 2008, then add the time part... and
convert that to datetime.
Hope this helps.
--
~lb


"Pingx" wrote:

Quote:
Fri Feb 29 16:46:39 America/Los_Angeles 2008

Hi, I'd like to know how I can convert the above string to a date.

Thanks in advance.

Pingx

Reply With Quote
  #6  
Old   
lonnye
 
Posts: n/a

Default RE: convert string to date - 03-16-2008 , 09:02 PM



Check out books online and look at the convert function.
It's syntax is CONVERT ( data_type [ ( length ) ] , expression [ , style ] ).
I dont have access to a sql server at this moment, but I would imagine doing
something like:
If Fri Feb 29 16:46:39 America/Los_Angeles 2008 were in a colum named
the_date...
declare @date_st varchar(30)
set @date_st = substring(5, 7, the_date) + substring(41, 4, the_date) +
substring(11,9, the_date)
convert(datetime, @date_st)
This is just off the top of my head so I apologize if anythign is wrong -
what I did was pull the Feb 29, add the 2008, then add the time part... and
convert that to datetime.
Hope this helps.
--
~lb


"Pingx" wrote:

Quote:
Fri Feb 29 16:46:39 America/Los_Angeles 2008

Hi, I'd like to know how I can convert the above string to a date.

Thanks in advance.

Pingx

Reply With Quote
  #7  
Old   
lonnye
 
Posts: n/a

Default RE: convert string to date - 03-16-2008 , 09:02 PM



Check out books online and look at the convert function.
It's syntax is CONVERT ( data_type [ ( length ) ] , expression [ , style ] ).
I dont have access to a sql server at this moment, but I would imagine doing
something like:
If Fri Feb 29 16:46:39 America/Los_Angeles 2008 were in a colum named
the_date...
declare @date_st varchar(30)
set @date_st = substring(5, 7, the_date) + substring(41, 4, the_date) +
substring(11,9, the_date)
convert(datetime, @date_st)
This is just off the top of my head so I apologize if anythign is wrong -
what I did was pull the Feb 29, add the 2008, then add the time part... and
convert that to datetime.
Hope this helps.
--
~lb


"Pingx" wrote:

Quote:
Fri Feb 29 16:46:39 America/Los_Angeles 2008

Hi, I'd like to know how I can convert the above string to a date.

Thanks in advance.

Pingx

Reply With Quote
  #8  
Old   
lonnye
 
Posts: n/a

Default RE: convert string to date - 03-16-2008 , 09:02 PM



Check out books online and look at the convert function.
It's syntax is CONVERT ( data_type [ ( length ) ] , expression [ , style ] ).
I dont have access to a sql server at this moment, but I would imagine doing
something like:
If Fri Feb 29 16:46:39 America/Los_Angeles 2008 were in a colum named
the_date...
declare @date_st varchar(30)
set @date_st = substring(5, 7, the_date) + substring(41, 4, the_date) +
substring(11,9, the_date)
convert(datetime, @date_st)
This is just off the top of my head so I apologize if anythign is wrong -
what I did was pull the Feb 29, add the 2008, then add the time part... and
convert that to datetime.
Hope this helps.
--
~lb


"Pingx" wrote:

Quote:
Fri Feb 29 16:46:39 America/Los_Angeles 2008

Hi, I'd like to know how I can convert the above string to a date.

Thanks in advance.

Pingx

Reply With Quote
  #9  
Old   
lonnye
 
Posts: n/a

Default RE: convert string to date - 03-16-2008 , 09:02 PM



Check out books online and look at the convert function.
It's syntax is CONVERT ( data_type [ ( length ) ] , expression [ , style ] ).
I dont have access to a sql server at this moment, but I would imagine doing
something like:
If Fri Feb 29 16:46:39 America/Los_Angeles 2008 were in a colum named
the_date...
declare @date_st varchar(30)
set @date_st = substring(5, 7, the_date) + substring(41, 4, the_date) +
substring(11,9, the_date)
convert(datetime, @date_st)
This is just off the top of my head so I apologize if anythign is wrong -
what I did was pull the Feb 29, add the 2008, then add the time part... and
convert that to datetime.
Hope this helps.
--
~lb


"Pingx" wrote:

Quote:
Fri Feb 29 16:46:39 America/Los_Angeles 2008

Hi, I'd like to know how I can convert the above string to a date.

Thanks in advance.

Pingx

Reply With Quote
  #10  
Old   
Pingx
 
Posts: n/a

Default RE: convert string to date - 03-16-2008 , 09:21 PM



Thanks Lonnye.
I used a PHP program to convert the string to a format in the book.
It was successful. But how do I handle the timezone?America/Los_Angeles
I need to have UTC date. Is there a function to convert the date according
to the timezone value?


"lonnye" wrote:

Quote:
Check out books online and look at the convert function.
It's syntax is CONVERT ( data_type [ ( length ) ] , expression [ , style ] ).
I dont have access to a sql server at this moment, but I would imagine doing
something like:
If Fri Feb 29 16:46:39 America/Los_Angeles 2008 were in a colum named
the_date...
declare @date_st varchar(30)
set @date_st = substring(5, 7, the_date) + substring(41, 4, the_date) +
substring(11,9, the_date)
convert(datetime, @date_st)
This is just off the top of my head so I apologize if anythign is wrong -
what I did was pull the Feb 29, add the 2008, then add the time part... and
convert that to datetime.
Hope this helps.
--
~lb


"Pingx" wrote:

Fri Feb 29 16:46:39 America/Los_Angeles 2008

Hi, I'd like to know how I can convert the above string to a date.

Thanks in advance.

Pingx

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.