ASP.NET - how to use date funtion in stored procedure and asp.net c#
Asked By bhanupratap singh on 25-Sep-12 05:58 AM
how to use SELECT CONVERT(Varchar(12),GetDate(), 103) for dd/MM/yyyyy.
My table coloumn is postingDate datatype is date in sql 2008
I want to select record from table where postingdate='25/09/2012'
how to do
thanks
Robbe Morris replied to bhanupratap singh on 25-Sep-12 09:25 AM
Jitendra Faye replied to bhanupratap singh on 26-Sep-12 01:51 AM
for this you can use different format while getting data from database. like Robbe suggested use DatePart.
manish postariya replied to bhanupratap singh on 26-Sep-12 03:32 PM
myCommand.Parameters.Add("@dateRegistered", SqlDbType.Date);
myCommand.Parameters["@dateRegistered"].Value = DateTime.Now.ToString("dd/mm/yyyy");
How can you always return a 2 digit month using datepart. Thanks. SQL Server Programming Discussions SQL Server (1) Convert (1) Try: select replace (str(datepart (mm, getdate ()), 2), ' ', '0') - - Tom - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Thomas A
Hi, I need some help on datetime function.I need to use sql server 2005 & i need to compare only the date portion with for the dates that are etc but they are not valid functions. I dont want to go for coding in sql query so kindly give some function name to be used for comparing only with the date parts. Hi Hiral if you want Date parts than there is function called DatePart in Sql server which can give you parts of your date and i think that
Hi!How can I keep the normal format calender It give me The month in the alphabetik order But when I am using the DATEPART() function I am getting the Value of the month as I need.But I want returns the name of the portion of the date and time variable. Just like the DATEPART function, the DATENAME function accepts two parameters the portion of the date that you want DateAdd( MONTH , number of MONTH , 0 ) - 1 ) Hope this will help you Regards D keywords: SQL Server, WEEKDAY, date, sql server 2005, date format, DATENAME, DATEPART description: Normal date format in sql
Create temp Table in Stored Procedure (Sql Server) SQL Server
What is the best way to create a temporary table to search in an SQL Stored Procedure? I want to search for all records that are included in a table don't know enought about writing queries to be sure this won't harm anything. SQL Code: CREATE PROCEDURE AcpReport_ByWorkorder(@WO nvarchar(10)) AS / * Created by Joe Pool - this pulls all WHERE ([Serial_Number] IN (SELECT Serial_Number FROM #t)) UNION SELECT [OP_ID], [Serial_Number], [Date_Time], 'ACP_Packout_' + SubString(Cast(DatePart(Year, Box_Data.Date_Time) AS VarChar(4)), 3, 2) AS [System_ID], 'Packed in ' + Box_Data.[Box_Number] AS EI.FIRSTNAME+' '+EI.LASTNAME WHERE ([Serial_Number] IN (SELECT Serial_Number FROM #t)) ORDER BY [Serial_Number] GO SQL Server Discussions CREATE PROCEDURE (1) CREATE TABLE (1) INNER JOIN (1) LEFT JOIN (1) Nvarchar
datepart question SQL Server
select datepart(mm, CAST(getdate() as varchar)) is 5 How can I get 'May' SQL Server Programming Discussions SQL Server (1) Varchar (1) Datetime (1) select datename(mm, CAST(getdate() as varchar)) marcmc, Use function
Get total seconds from DateTime field SQL Server
SQL Server 2000 How may I get the total seconds (or minutes and seconds) from a DateTime 01 000:00:55 000:00:59 000:01:02 Thanks for any help. Adrian. SQL Server Programming Discussions SQL Server 2000 (1) HiCREATE (1) CREATE FUNCTION (1) Database (1) PostTime (1) Adventureworks (1) DATEDIFF (1
ADO adDBtimeStamp maps to a DATETIME type in SQL Server SQL Server
I have a smalldatetime in SQL table, and I want to get this datetime in the format yyyy-mm-dd hh this's not a elegant way. Because in the case, I have to change many sql sentences to fix the problem. Any suggestion? Thanks in advance. SQL Server Discussions SQL Server (1) Smalldatetime (1) Date (1) VB (1) MyDateTime.Format (1) AdDBtimeStamp (1
Differential backup problem SQL Server
SQL Server 2005 express. To automate the backup process, I am using SQLCMD along with windows schedulers fails 4:00 am onward. What is the problem? Any help would be appreciated. Thanks SQL Server Programming Discussions Backup (1) SQL Server (1) CREATE PROCEDURE (1) Database (1) Smalldatetime (1) Every (1) Operation (1) Databases (1) JJ
TSQL Date help SQL Server
SQL Server 2000 SP4 - Windows 2003 SP2. I have a query that creates a report for monthly to_date = '6 / 1 / 2010' - - set to the first of the next month - -> > '6 / 1 / 2010' SQL Server Discussions SQL Server 2000 (1) Declare (1) Date (1) Thanks Erland (1) Database (1) Report (1) PM (1
hi sir, plz send me date format for 20th jan 2005, plz send me the query. 106 is format code. SQL statement would be SELECT CONVERT(VARCHAR(11), GETDATE(), 106) AS [DD MON YYYY] But the requested to display date with st, nd, rd and th: Query: Select Convert(nvarchar(2), DatePart(dd, datefiled)) + Case DatePart(dd, datefiled) % 10 When 1 Then 'st' When 2 Then 'nd' When 3 Then 'rd Else 'th' End + ' ' + Convert(nvarchar(3), Datename(month, datefiled)) + ' ' + Convert(nvarchar(4), DatePart(yyyy, datefiled))as datefiled From tablename Output: 6th Jan 2010 SELECT STUFF(CONVERT(char(11