Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Change the date format inside a Procedure

Author  Topic 

Smoldar
Starting Member

3 Posts

Posted - 2010-04-15 : 13:55:46
I'm making quite a few procedures, and in about 4 of them, i need to change de dateformat to dd/mm/yyyy.

And only inside that procedure.

Is that possible?

This is the procedure that i'm currently using. The users are making complaints about having to type mm/dd/yyyy to use the functions.

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON
GO

@@AACIDNST DATETIME,
@@AACIDNED DATETIME
AS
BEGIN
SET NOCOUNT ON
DECLARE @CERROSQL INT

BEGIN TRAN
SELECT COUNT(AACIDN)
AS QTD_TOTAL
FROM dbo.TB_ACIDNAMBNT
WHERE AACIDN BETWEEN @@AACIDNST AND @@AACIDNED
SET @CERROSQL = @@ERROR
IF (@CERROSQL <> 0)
BEGIN
RAISERROR (@CERROSQL, 16, 1)
ROLLBACK TRAN
RETURN -1
END
COMMIT TRAN
SET NOCOUNT OFF
END
RETURN

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO



It's possible to change the date ONLY while the procedure is running?

DBA in the making
Aged Yak Warrior

638 Posts

Posted - 2010-04-15 : 14:00:04
Date formatting is handled by the client, not the server. When you say users are entering dates, what are they entering them into? If it's a client application, then that's where the dates should be formatted. Once they're passed to the stored proc (and are stored in a DATETIME datatype), they don't have a format.

------------------------------------------------------------------------------------
Any and all code contained within this post comes with a 100% money back guarantee.
Go to Top of Page

Smoldar
Starting Member

3 Posts

Posted - 2010-04-15 : 14:39:10
Users are using a php page to input the dates.

This one is a page to generate a pie graph. They input the Start date and the End date (Say, for example: 01/01/09 to 12/31/09) and a pie graph for that period is show on screen.

If it helps, i can post de php code here too.

The hole system, but the small part is based only in years, already up and running and don't have any kind of documentation whatsoever. That is why i having a hard time to make this.
Go to Top of Page

DBA in the making
Aged Yak Warrior

638 Posts

Posted - 2010-04-15 : 17:00:57
Have you checked the regional settings on the web server? I'm not any sort of expert on php, so I really couldn't offer much more help. Perhaps a php forum would be able to help more.

------------------------------------------------------------------------------------
Any and all code contained within this post comes with a 100% money back guarantee.
Go to Top of Page

Smoldar
Starting Member

3 Posts

Posted - 2010-04-16 : 08:29:53
I came here, to find out if it's possible to do it in SQL, but since it can't be done, i thank you for your time and help ^^

Gona search for some good php forum so i can ask there. Many thanks again =D
Go to Top of Page
   

- Advertisement -