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
 General SQL Server Forums
 New to SQL Server Programming
 smalldatetime
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

seeker62
Starting Member

40 Posts

Posted - 01/30/2013 :  15:23:21  Show Profile  Reply with Quote
I have this piece of code in a sp:

SET WeekOf = RTRIM(Left(DATEADD(dd, DATEDIFF(dd,0,sd.LoadDAte)/7*7,0),10))

I am trying to just have the mm/dd/yyy and not hh:mm:ss in my smalldatetime field in the table. Is there a way to do this?

Lamprey
Flowing Fount of Yak Knowledge

4613 Posts

Posted - 01/30/2013 :  15:24:50  Show Profile  Reply with Quote
CAST(<DateTimeValue> AS DATE)
Go to Top of Page

seeker62
Starting Member

40 Posts

Posted - 01/30/2013 :  15:58:29  Show Profile  Reply with Quote
This puts mm/dd/yyyy 00:00:00 which then comes into my spreadsheet as mm/dd/yyyy 12:00:00 AM I have tried formating the cell in the spreadsheet but it is developed by code and evidently the control i am using does not have a date for a format of a cell. It has datetime. I suppose i could change datatype in table to varchar
Go to Top of Page

seeker62
Starting Member

40 Posts

Posted - 01/30/2013 :  16:05:51  Show Profile  Reply with Quote
Found a workaround

DateTime dtWeekOf = DateTime.Parse(dr["WeekOf"].ToString());
row.Cells.Add(dtWeekOf.ToString("s"), DataType.DateTime, "DateFormat");

Thanks.
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.05 seconds. Powered By: Snitz Forums 2000