February 10, 2004 at 1:04 pm
How can i make auto number from the first day of the year?
How can I make this?
From the binging of the year
In the date of
1-2004 And after. 2-2004 .. 3-2004 ……………………………….. 99-2004
AND until the end of the year of 2004
AND in the beginning of the year 2005 from the date
The number will start from the number 1-2005 and after 2-2005 ………. 99-2005
And I wont every year in the beginning of the year the number will start from
1
Tanks
ilan
February 10, 2004 at 1:22 pm
SELECT convert(varchar(3), DATEDIFF ( day , '01/01/2004' , getdate())) + '-' + convert(varchar(4), YEAR(getdate()))
February 10, 2004 at 1:35 pm
And what abut the auto number from the beginning of the year that
I wont that the number start from 1
until the end of the year !!!
And start in the next year from 1
until the end of the year !!!
thaks
ilan
February 10, 2004 at 1:37 pm
And what abut the auto number from the beginning of the year that
I wont that the number start from 1
until the end of the year !!!
And start in the next year from 1
until the end of the year !!!
thaks
ilan
February 10, 2004 at 8:56 pm
Check the answer from your another posting "new year new number Generating in SQL server"
Regards,
kokyan
February 11, 2004 at 12:53 am
SELECT convert(varchar(3), DATEDIFF ( day , '01/Jan/'+ltrim(str(year(getdate()))) , getdate())) + '-' + convert(varchar(4), YEAR(getdate()))
This Will Solve the Problem, remember very first number will be zero.
Manish
February 11, 2004 at 5:14 am
SQL Server can provide the values you want using DatePart ( dy, <date> ).
Try these examples:
declare @date datetime
set @date = '1/1/2003'
SELECT Convert(varchar(3), DatePart(dy, @date)) + '-' + Convert(varchar(4), Year(@date))
set @date = '1/2/2003'
SELECT Convert(varchar(3), DatePart(dy, @date)) + '-' + Convert(varchar(4), Year(@date))
set @date = '12/31/2003'
SELECT Convert(varchar(3), DatePart(dy, @date)) + '-' + Convert(varchar(4), Year(@date))
set @date = '1/1/2004'
SELECT Convert(varchar(3), DatePart(dy, @date)) + '-' + Convert(varchar(4), Year(@date))
Mike
February 11, 2004 at 5:35 am
Just noticed. Please do not cross post. Related thread http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=99652
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply