SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Update Date Column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Sonu619
Posting Yak Master

195 Posts

Posted - 07/20/2012 :  02:25:47  Show Profile  Reply with Quote
Hi guys,

I have column Sale_date and below is sample data

Sale_Date
05/22/2011
06/15/2010
09/22/2011

How i can update Sale_Date Column so End result would be

Sale_Date
5/22/11
6/15/10
9/22/11

Thanks For help..

webfred
Flowing Fount of Yak Knowledge

Germany
8515 Posts

Posted - 07/20/2012 :  02:40:58  Show Profile  Visit webfred's Homepage  Reply with Quote
The data type of that column is what?
Do you need that format for display purpose?
Can you do that in your front end?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Sonu619
Posting Yak Master

195 Posts

Posted - 07/20/2012 :  11:03:56  Show Profile  Reply with Quote
Data Type for Column is Varchar. I am trying to automate Report in SSRS so user can select what kinda report they want and print by self and they want to see this kinda format.I tried to fix through SSRS Expression but no luck so i am thinking to update after upload table update date field.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47188 Posts

Posted - 07/20/2012 :  11:12:08  Show Profile  Reply with Quote
quote:
Originally posted by Sonu619

Data Type for Column is Varchar. I am trying to automate Report in SSRS so user can select what kinda report they want and print by self and they want to see this kinda format.I tried to fix through SSRS Expression but no luck so i am thinking to update after upload table update date field.


whats the basic datatype of field is it varchar or datetime?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Lamprey
Flowing Fount of Yak Knowledge

3833 Posts

Posted - 07/20/2012 :  11:47:48  Show Profile  Reply with Quote
Even though this is probalby realy bad thung to do, here is some code that'll get you close. It will pad a leading zero to single digit months. So, if you need to remove that you'll have to add a little more code to remove that.
DECLARE @Foo TABLE(Val VARCHAR(20))

INSERT @Foo
VALUES 
	('05/22/2011'),
	('06/15/2010'),
	('09/22/2011')


UPDATE @Foo
SET Val = CONVERT(VARCHAR(8), CONVERT(DATETIME, Val, 101), 1) 

SELECT * 
FROM @Foo
EDIT: cut-n-past error.

Edited by - Lamprey on 07/20/2012 11:50:06
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47188 Posts

Posted - 07/20/2012 :  14:13:08  Show Profile  Reply with Quote
quote:
Originally posted by Sonu619

Data Type for Column is Varchar. I am trying to automate Report in SSRS so user can select what kinda report they want and print by self and they want to see this kinda format.I tried to fix through SSRS Expression but no luck so i am thinking to update after upload table update date field.


what SSRS expression you were using? did you try FormatDatetime() function

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47188 Posts

Posted - 07/20/2012 :  14:13:08  Show Profile  Reply with Quote
quote:
Originally posted by Sonu619

Data Type for Column is Varchar. I am trying to automate Report in SSRS so user can select what kinda report they want and print by self and they want to see this kinda format.I tried to fix through SSRS Expression but no luck so i am thinking to update after upload table update date field.


what SSRS expression you were using? did you try FormatDatetime() function

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Sonu619
Posting Yak Master

195 Posts

Posted - 07/21/2012 :  00:50:11  Show Profile  Reply with Quote
My source file date, datatype if varchar....
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000