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
 Date Variable

Author  Topic 

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2011-02-04 : 04:38:10
Hello there.

I have two date variable one for 1st day in month before present.

and one for last day in month before present.

( SELECT DATEADD(month,datediff(month,0,getdate())-1,0))


( select DATEADD(month,datediff(month,0,getdate()),0)-1 )

the format come out like 2011-01-31 00:00:00.000

how do i change to make the month come as follows

2011-jan-31 00:00:00.000

kind Regards

Rob

MCTS / MCITP certified

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-04 : 04:41:01
Formation matters only if you want to show data somewhere. Where do you want to show data?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2011-02-04 : 05:00:52
ok how do i change the date formate from yyyy-mm-dd to dd-mm-yyyy
Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2011-02-04 : 05:23:28
no worries.

done it!

SELECT CONVERT(VARCHAR(20), dbo.USER DEFINED DATE FUNCTION(), 106)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-04 : 05:45:07
quote:
Originally posted by masterdineen

no worries.

done it!

SELECT CONVERT(VARCHAR(20), dbo.USER DEFINED DATE FUNCTION(), 106)


Note that the date values become varchars

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2011-02-04 : 06:14:02
yes i have noticed that.
Go to Top of Page
   

- Advertisement -